Contents of /trunk/cpio/patches/cpio-2.9-restore-perms-owners.patch
Parent Directory | Revision Log
Revision 725 -
(show annotations)
(download)
Mon Dec 22 23:30:56 2008 UTC (15 years, 9 months ago) by niro
File size: 3082 byte(s)
Mon Dec 22 23:30:56 2008 UTC (15 years, 9 months ago) by niro
File size: 3082 byte(s)
-added several cpio fixes
1 | http://bugs.gentoo.org/218040 |
2 | |
3 | fix from upstream to restore owners/perms in some situations |
4 | |
5 | --- cpio-2.9/src/extern.h |
6 | +++ cpio-2.9/src/extern.h |
7 | @@ -211,7 +211,7 @@ uintmax_t from_ascii (char const *where, |
8 | |
9 | void delay_set_stat (char const *file_name, struct stat *st, |
10 | mode_t invert_permissions); |
11 | -void repair_delayed_set_stat (char const *dir, |
12 | +int repair_delayed_set_stat (char const *dir, |
13 | struct stat *dir_stat_info); |
14 | void apply_delayed_set_stat (void); |
15 | |
16 | --- cpio-2.9/src/copyin.c |
17 | +++ cpio-2.9/src/copyin.c |
18 | @@ -570,6 +570,7 @@ static void |
19 | copyin_directory (struct cpio_file_stat *file_hdr, int existing_dir) |
20 | { |
21 | int res; /* Result of various function calls. */ |
22 | + struct stat file_stat; |
23 | #ifdef HPUX_CDF |
24 | int cdf_flag; /* True if file is a CDF. */ |
25 | int cdf_char; /* Index of `+' char indicating a CDF. */ |
26 | @@ -626,7 +627,6 @@ copyin_directory (struct cpio_file_stat |
27 | create_all_directories(), so the mkdir will fail |
28 | because the directory exists. If that's the case, |
29 | don't complain about it. */ |
30 | - struct stat file_stat; |
31 | if (errno != EEXIST) |
32 | { |
33 | mkdir_error (file_hdr->c_name); |
34 | @@ -645,7 +645,11 @@ copyin_directory (struct cpio_file_stat |
35 | } |
36 | } |
37 | |
38 | - set_perms (-1, file_hdr); |
39 | + /* if the directory is queued for delayed_set_stat, |
40 | + fix permissions in the queue, otherwise set the permissions now */ |
41 | + void cpio_to_stat (struct cpio_file_stat *hdr, struct stat *st); cpio_to_stat(file_hdr, &file_stat); |
42 | + if (repair_delayed_set_stat(file_hdr->c_name, &file_stat)) |
43 | + set_perms (-1, file_hdr); |
44 | } |
45 | |
46 | static void |
47 | --- cpio-2.9/src/util.c |
48 | +++ cpio-2.9/src/util.c |
49 | @@ -1265,6 +1265,16 @@ stat_to_cpio (struct cpio_file_stat *hdr |
50 | hdr->c_tar_linkname = NULL; |
51 | } |
52 | |
53 | +void |
54 | +cpio_to_stat (struct cpio_file_stat *hdr, struct stat *st) |
55 | +{ |
56 | + stat (hdr->c_name, st); |
57 | + st->st_mode = hdr->c_mode; |
58 | + st->st_uid = CPIO_UID(hdr->c_uid); |
59 | + st->st_gid = CPIO_GID(hdr->c_gid); |
60 | + st->st_mtime = hdr->c_mtime; |
61 | +} |
62 | + |
63 | #ifndef HAVE_FCHOWN |
64 | # define fchown(fd, uid, gid) (-1) |
65 | #endif |
66 | @@ -1389,7 +1399,7 @@ delay_set_stat (char const *file_name, s |
67 | created within the file name of DIR. The intermediate directory turned |
68 | out to be the same as this directory, e.g. due to ".." or symbolic |
69 | links. *DIR_STAT_INFO is the status of the directory. */ |
70 | -void |
71 | +int |
72 | repair_delayed_set_stat (char const *dir, |
73 | struct stat *dir_stat_info) |
74 | { |
75 | @@ -1400,22 +1410,19 @@ repair_delayed_set_stat (char const *dir |
76 | if (stat (data->stat.c_name, &st) != 0) |
77 | { |
78 | stat_error (data->stat.c_name); |
79 | - return; |
80 | + return 0; |
81 | } |
82 | |
83 | if (st.st_dev == dir_stat_info->st_dev |
84 | && st.st_ino == dir_stat_info->st_ino) |
85 | { |
86 | stat_to_cpio (&data->stat, dir_stat_info); |
87 | - data->invert_permissions = |
88 | - ((dir_stat_info->st_mode ^ st.st_mode) |
89 | - & MODE_RWX & ~ newdir_umask); |
90 | - return; |
91 | + data->invert_permissions = 0; |
92 | + return 0; |
93 | } |
94 | } |
95 | |
96 | - ERROR ((0, 0, _("%s: Unexpected inconsistency when making directory"), |
97 | - quotearg_colon (dir))); |
98 | + return -1; |
99 | } |
100 | |
101 | void |