stages: 2/02-squashfs: apply some patches from Debian to make the ISO more reliable
[dragora.git] / patches / squashfs-tools / 0015-numeric-uid-gid_to_unsquashfs.patch
blob72bcd6e9e80328217f23880b8b0f82d2f6a4cf4e
1 --- a/squashfs-tools/unsquashfs.c
2 +++ b/squashfs-tools/unsquashfs.c
3 @@ -63,7 +63,7 @@ char *file_data;
4 char *data;
5 unsigned int block_size;
6 unsigned int block_log;
7 -int lsonly = FALSE, info = FALSE, force = FALSE, short_ls = TRUE;
8 +int lsonly = FALSE, info = FALSE, force = FALSE, short_ls = TRUE, numeric_ls = FALSE;
9 int use_regex = FALSE;
10 char **created_inode;
11 int root_process;
12 @@ -518,8 +518,8 @@ int print_filename(char *pathname, struc
13 char str[11], dummy[12], dummy2[12]; /* overflow safe */
14 char *userstr, *groupstr;
15 int padchars;
16 - struct passwd *user;
17 - struct group *group;
18 + struct passwd *user = NULL;
19 + struct group *group = NULL;
20 struct tm *t;
22 if(short_ls) {
23 @@ -527,8 +527,9 @@ int print_filename(char *pathname, struc
24 return 1;
27 - user = getpwuid(inode->uid);
28 - if(user == NULL) {
29 + if(!numeric_ls)
30 + user = getpwuid(inode->uid);
31 + if(user == NULL || numeric_ls) {
32 int res = snprintf(dummy, 12, "%d", inode->uid);
33 if(res < 0)
34 EXIT_UNSQUASH("snprintf failed in print_filename()\n");
35 @@ -541,8 +542,9 @@ int print_filename(char *pathname, struc
36 } else
37 userstr = user->pw_name;
39 - group = getgrgid(inode->gid);
40 - if(group == NULL) {
41 + if(!numeric_ls)
42 + group = getgrgid(inode->gid);
43 + if(group == NULL || numeric_ls) {
44 int res = snprintf(dummy2, 12, "%d", inode->gid);
45 if(res < 0)
46 EXIT_UNSQUASH("snprintf failed in print_filename()\n");
47 @@ -2643,6 +2645,11 @@ int main(int argc, char *argv[])
48 strcmp(argv[i], "-ll") == 0) {
49 lsonly = TRUE;
50 short_ls = FALSE;
51 + } else if(strcmp(argv[i], "-nls") == 0 ||
52 + strcmp(argv[i], "-nl") == 0) {
53 + lsonly = TRUE;
54 + short_ls = FALSE;
55 + numeric_ls = TRUE;
56 } else if(strcmp(argv[i], "-linfo") == 0 ||
57 strcmp(argv[i], "-li") == 0) {
58 info = TRUE;
59 @@ -2705,6 +2712,9 @@ options:
60 ERROR("\t-ll[s]\t\t\tlist filesystem with file "
61 "attributes (like\n");
62 ERROR("\t\t\t\tls -l output), but don't unsquash\n");
63 + ERROR("\t-nl[s]\t\t\tlist filesystem with file "
64 + "attributes (like\n");
65 + ERROR("\t\t\t\tls -n output), but don't unsquash\n");
66 ERROR("\t-f[orce]\t\tif file already exists then "
67 "overwrite\n");
68 ERROR("\t-s[tat]\t\t\tdisplay filesystem superblock "