-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
track file mode and ownership in files.plist #541
base: master
Are you sure you want to change the base?
Conversation
13a194d
to
66747bf
Compare
Yes see last point "is there anywhere else where this metadata would be useful?".
I guess that wouldn't hurt could track that information but don't error if it changes maybe.
BSDs have Might be nice to have in libxbps to also use in debug or error messages for file conflicts.
I've written some code for
I would just add a simple basic test for both For For
I think it would be good to extend this to directories, then also track the mode in Regarding UID/GIDs, I think it would be better to default to root and optionally allow to set a The PR looks good and I think we can merge this fast so that we don't have this sitting around for too long. |
3775688
to
2a8058a
Compare
bin/xbps-query/show-info-files.c
Outdated
if (long_listing) { | ||
// TODO: do with xbps_fmt_* api | ||
// mode_t mode = 0; | ||
// uint64_t size = 0; | ||
// char hmode[10], *owner = NULL, *group = NULL; | ||
// if (xbps_dictionary_get_uint32(obj, "mode", &mode)) { | ||
// xbps_strmode(mode, hmode); | ||
// printf("%s\t", hmode); | ||
// } else { | ||
// printf("?\t"); | ||
// } | ||
// if (xbps_dictionary_get_cstring_nocopy(obj, "owner", owner)) | ||
// printf("%s\t", owner); | ||
// else | ||
// printf("?\t"); | ||
|
||
// if (xbps_dictionary_get_cstring_nocopy(obj, "group", group)) | ||
// printf("%s\t", group); | ||
// else | ||
// printf("?\t"); | ||
|
||
// if (xbps_dictionary_get_uint64(obj, "size", &size)) | ||
// printf("%lu\t", size); | ||
// else | ||
// printf("?\t"); | ||
} |
Check notice
Code scanning / CodeQL
Futile conditional
I see what you're getting at with tracking the owner/group name rather than id: I was assuming they would be uniform across systems, which is ofc not correct.
I'm not sure I see where the directory handling code is? from what I read xbps-create doesn't bundle empty dirs. are you talking about non-empty dirs here? |
This would need new code to first store empty directories in files.plist and then also create them when extracting the package. But I think this can wait for a second PR, getting the metadata in and having the basic support for file checks is good. |
Also I'm generally moving into the direction of making functions return |
2a8058a
to
c979128
Compare
@@ -22,6 +22,9 @@ | |||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
*/ | |||
|
|||
#define _DEFAULT_SOURCE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed for strsep()
. is this the right spot to put it?
949ba56
to
a5c1700
Compare
@@ -109,6 +114,9 @@ usage(bool fail) | |||
" 'vi:/usr/bin/vi:/usr/bin/vim foo:/usr/bin/foo:/usr/bin/blah'\n" | |||
" --build-options A string with the used build options\n" | |||
" --compression Compression format: none, gzip, bzip2, lz4, xz, zstd (default)\n" | |||
" --chown Set the ownership of files and directories.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't handle paths with spaces... maybe accepting the argument multiple times would be better, or is this not a concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something else to consider: should chown -R
be representable?
a5c1700
to
5e4fe4a
Compare
5e4fe4a
to
c67b024
Compare
c67b024
to
ffa9ad5
Compare
7ef588c
to
74dab9b
Compare
ok pkgdb is updated to use the idtree cache. I think all that remains is writing some tests. |
74dab9b
to
46c7ac5
Compare
@Duncaen ready for further review |
799758c
to
fdaa0e6
Compare
General code style changes: Braces of functions on new line:
Switch cases not indented:
|
I feel like the file_{mode,user,group} functions are unnecessary, duplicate a lot of error handling and system calls:
You'll also have to use different id trees for users and groups since its not required that there is a primary group with the gid being the same as the uid. Maybe also don't check if user and/or group are not set since the metadata will not be there for some time and would produce errors. |
All comments are generally old c-style |
Looking over this, the idtree was probably not the right choice what we generally need is a map from names to uids, that makes the code a lot simpler. The idtree makes sense if we need to find the name from ids, using the idtree to compare strings after search the tree doesn't make much sense. |
for printing file permissions and type
also add a couple missing things to the xbps_create completions
fdaa0e6
to
8f483c6
Compare
style issues fixed (except where refactor will happen) what data structure should be used for a mapping then? could xbps_dictionary be used? |
I would just use uthash, we using it already and I don't really like the proplib api, it tends to hide errors. Not sure about the name of the functions/api, generally combining users and groups behind the same api makes sense I think. Not sure if we should read the whole passwd or groups file when creating the cache or looking them up on demand.
Damn also noticing this now while thinking about the api we can't really using the default libc api, because we need to take rootdir into account. |
With having to take rootdir into account, how would we avoid nss with glibc. Anyways, we probably should read With that in mind I guess we do should split the api:
|
fixes #514
Questions
print_mode()
?--long -f
output include the mtime?--long -f
output look more likels -l
? (e.g. single space between columns, right justify size, etc)--long -f
?Examples
another example of
xbps-query --long -f
, with files that actually have sizes: