Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/mkdir-p.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | _Bool | - | ||||||||||||||||||
8 | - | |||||||||||||||||||
9 | make_dir_parents (char *dir, | - | ||||||||||||||||||
10 | struct savewd *wd, | - | ||||||||||||||||||
11 | int (*make_ancestor) (char const *, char const *, void *), | - | ||||||||||||||||||
12 | void *options, | - | ||||||||||||||||||
13 | mode_t mode, | - | ||||||||||||||||||
14 | void (*announce) (char const *, void *), | - | ||||||||||||||||||
15 | mode_t mode_bits, | - | ||||||||||||||||||
16 | uid_t owner, | - | ||||||||||||||||||
17 | gid_t group, | - | ||||||||||||||||||
18 | - | |||||||||||||||||||
19 | _Bool | - | ||||||||||||||||||
20 | preserve_existing) | - | ||||||||||||||||||
21 | { | - | ||||||||||||||||||
22 | int mkdir_errno = (((((
| 0-10279 | ||||||||||||||||||
23 | - | |||||||||||||||||||
24 | if (mkdir_errno == 0
| 0-10281 | ||||||||||||||||||
25 | { | - | ||||||||||||||||||
26 | ptrdiff_t prefix_len = 0; | - | ||||||||||||||||||
27 | int savewd_chdir_options = (1 ? SAVEWD_CHDIR_SKIP_READABLE : 0 dead code: );0 | - | ||||||||||||||||||
28 | - | |||||||||||||||||||
29 | if (make_ancestor
| 123-10158 | ||||||||||||||||||
30 | { | - | ||||||||||||||||||
31 | prefix_len = mkancesdirs (dir, wd, make_ancestor, options); | - | ||||||||||||||||||
32 | if (prefix_len < 0
| 5-118 | ||||||||||||||||||
33 | { | - | ||||||||||||||||||
34 | if (prefix_len < -1
| 1-4 | ||||||||||||||||||
35 | return executed 4 times by 1 test: return 1 ; Executed by:
executed 4 times by 1 test: return 1 ; Executed by:
| 4 | ||||||||||||||||||
36 | 1 executed 4 times by 1 test: return 1 ; Executed by:
| 4 | ||||||||||||||||||
37 | ; executed 4 times by 1 test: return 1 ; Executed by:
| 4 | ||||||||||||||||||
38 | mkdir_errno = | - | ||||||||||||||||||
39 | (*__errno_location ()) | - | ||||||||||||||||||
40 | ; | - | ||||||||||||||||||
41 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
42 | } executed 119 times by 2 tests: end of block Executed by:
| 119 | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | if (0 <= prefix_len
| 1-10276 | ||||||||||||||||||
45 | { | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | - | |||||||||||||||||||
48 | - | |||||||||||||||||||
49 | - | |||||||||||||||||||
50 | - | |||||||||||||||||||
51 | - | |||||||||||||||||||
52 | _Bool | - | ||||||||||||||||||
53 | keep_owner = owner == (uid_t) -1
| 0-10276 | ||||||||||||||||||
54 | - | |||||||||||||||||||
55 | _Bool | - | ||||||||||||||||||
56 | keep_special_mode_bits = | - | ||||||||||||||||||
57 | ((mode_bits & ( | - | ||||||||||||||||||
58 | 04000 | - | ||||||||||||||||||
59 | | | - | ||||||||||||||||||
60 | 02000 | - | ||||||||||||||||||
61 | )) | (mode & | - | ||||||||||||||||||
62 | 01000 | - | ||||||||||||||||||
63 | )) == 0; | - | ||||||||||||||||||
64 | mode_t mkdir_mode = mode; | - | ||||||||||||||||||
65 | if (! keep_owner
| 0-10276 | ||||||||||||||||||
66 | mkdir_mode &= ~ ( never executed: mkdir_mode &= ~ ( ((0400|0200|0100) >> 3) | (((0400|0200|0100) >> 3) >> 3) ); | 0 | ||||||||||||||||||
67 | ((0400|0200|0100) >> 3) never executed: mkdir_mode &= ~ ( ((0400|0200|0100) >> 3) | (((0400|0200|0100) >> 3) >> 3) ); | 0 | ||||||||||||||||||
68 | | never executed: mkdir_mode &= ~ ( ((0400|0200|0100) >> 3) | (((0400|0200|0100) >> 3) >> 3) ); | 0 | ||||||||||||||||||
69 | (((0400|0200|0100) >> 3) >> 3) never executed: mkdir_mode &= ~ ( ((0400|0200|0100) >> 3) | (((0400|0200|0100) >> 3) >> 3) ); | 0 | ||||||||||||||||||
70 | ); never executed: mkdir_mode &= ~ ( ((0400|0200|0100) >> 3) | (((0400|0200|0100) >> 3) >> 3) ); | 0 | ||||||||||||||||||
71 | else if (! keep_special_mode_bits
| 8-10268 | ||||||||||||||||||
72 | mkdir_mode &= ~ ( executed 8 times by 1 test: mkdir_mode &= ~ ( (0200 >> 3) | ((0200 >> 3) >> 3) ); Executed by:
| 8 | ||||||||||||||||||
73 | (0200 >> 3) executed 8 times by 1 test: mkdir_mode &= ~ ( (0200 >> 3) | ((0200 >> 3) >> 3) ); Executed by:
| 8 | ||||||||||||||||||
74 | | executed 8 times by 1 test: mkdir_mode &= ~ ( (0200 >> 3) | ((0200 >> 3) >> 3) ); Executed by:
| 8 | ||||||||||||||||||
75 | ((0200 >> 3) >> 3) executed 8 times by 1 test: mkdir_mode &= ~ ( (0200 >> 3) | ((0200 >> 3) >> 3) ); Executed by:
| 8 | ||||||||||||||||||
76 | ); executed 8 times by 1 test: mkdir_mode &= ~ ( (0200 >> 3) | ((0200 >> 3) >> 3) ); Executed by:
| 8 | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | if (mkdir (dir + prefix_len, mkdir_mode) == 0
| 3-10273 | ||||||||||||||||||
79 | { | - | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | - | |||||||||||||||||||
82 | - | |||||||||||||||||||
83 | _Bool | - | ||||||||||||||||||
84 | umask_must_be_ok = (mode & mode_bits & | - | ||||||||||||||||||
85 | ((0400|0200|0100) | ((0400|0200|0100) >> 3) | (((0400|0200|0100) >> 3) >> 3)) | - | ||||||||||||||||||
86 | ) == 0; | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | announce (dir, options); | - | ||||||||||||||||||
89 | preserve_existing = (keep_owner & keep_special_mode_bits | - | ||||||||||||||||||
90 | & umask_must_be_ok); | - | ||||||||||||||||||
91 | savewd_chdir_options |= SAVEWD_CHDIR_NOFOLLOW; | - | ||||||||||||||||||
92 | } executed 10273 times by 2 tests: end of block Executed by:
| 10273 | ||||||||||||||||||
93 | else | - | ||||||||||||||||||
94 | { | - | ||||||||||||||||||
95 | mkdir_errno = | - | ||||||||||||||||||
96 | (*__errno_location ()) | - | ||||||||||||||||||
97 | ; | - | ||||||||||||||||||
98 | mkdir_mode = -1; | - | ||||||||||||||||||
99 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | if (preserve_existing
| 9-10267 | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | struct stat st; | - | ||||||||||||||||||
104 | if (mkdir_errno == 0
| 0-10267 | ||||||||||||||||||
105 | || (mkdir_errno !=
| 0 | ||||||||||||||||||
106 | 2
| 0 | ||||||||||||||||||
107 | && make_ancestor
| 0 | ||||||||||||||||||
108 | && stat (dir + prefix_len, &st) == 0
| 0 | ||||||||||||||||||
109 | && | - | ||||||||||||||||||
110 | ((((
| 0 | ||||||||||||||||||
111 | st.st_mode
| 0 | ||||||||||||||||||
112 | )) & 0170000) == (0040000))
| 0 | ||||||||||||||||||
113 | )) | - | ||||||||||||||||||
114 | return executed 10267 times by 1 test: return 1 ; Executed by:
executed 10267 times by 1 test: return 1 ; Executed by:
| 10267 | ||||||||||||||||||
115 | 1 executed 10267 times by 1 test: return 1 ; Executed by:
| 10267 | ||||||||||||||||||
116 | ; executed 10267 times by 1 test: return 1 ; Executed by:
| 10267 | ||||||||||||||||||
117 | } never executed: end of block | 0 | ||||||||||||||||||
118 | else | - | ||||||||||||||||||
119 | { | - | ||||||||||||||||||
120 | int open_result[2]; | - | ||||||||||||||||||
121 | int chdir_result = | - | ||||||||||||||||||
122 | savewd_chdir (wd, dir + prefix_len, | - | ||||||||||||||||||
123 | savewd_chdir_options, open_result); | - | ||||||||||||||||||
124 | if (chdir_result < -1
| 0-9 | ||||||||||||||||||
125 | return never executed: return 1 ; never executed: return 1 ; | 0 | ||||||||||||||||||
126 | 1 never executed: return 1 ; | 0 | ||||||||||||||||||
127 | ; never executed: return 1 ; | 0 | ||||||||||||||||||
128 | else | - | ||||||||||||||||||
129 | { | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | _Bool | - | ||||||||||||||||||
132 | chdir_ok = (chdir_result == 0); | - | ||||||||||||||||||
133 | char const *subdir = (chdir_ok
| 0-9 | ||||||||||||||||||
134 | if (dirchownmod (open_result[0], subdir, mkdir_mode,
| 0-9 | ||||||||||||||||||
135 | owner, group, mode, mode_bits)
| 0-9 | ||||||||||||||||||
136 | == 0
| 0-9 | ||||||||||||||||||
137 | return executed 9 times by 2 tests: return 1 ; Executed by:
executed 9 times by 2 tests: return 1 ; Executed by:
| 9 | ||||||||||||||||||
138 | 1 executed 9 times by 2 tests: return 1 ; Executed by:
| 9 | ||||||||||||||||||
139 | ; executed 9 times by 2 tests: return 1 ; Executed by:
| 9 | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | if (mkdir_errno == 0
| 0 | ||||||||||||||||||
142 | || (mkdir_errno !=
| 0 | ||||||||||||||||||
143 | 2
| 0 | ||||||||||||||||||
144 | && make_ancestor
| 0 | ||||||||||||||||||
145 | && | - | ||||||||||||||||||
146 | (*
| 0 | ||||||||||||||||||
147 | !=
| 0 | ||||||||||||||||||
148 | 20
| 0 | ||||||||||||||||||
149 | )) | - | ||||||||||||||||||
150 | { | - | ||||||||||||||||||
151 | error (0, | - | ||||||||||||||||||
152 | (*__errno_location ()) | - | ||||||||||||||||||
153 | , | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | dcgettext (((void *)0), | - | ||||||||||||||||||
156 | keep_owner ? "cannot change permissions of %s" : "cannot change owner and permissions of %s" | - | ||||||||||||||||||
157 | , 5) | - | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | - | |||||||||||||||||||
160 | , | - | ||||||||||||||||||
161 | quote (dir)); | - | ||||||||||||||||||
162 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||
163 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||
164 | ; never executed: return 0 ; | 0 | ||||||||||||||||||
165 | } | - | ||||||||||||||||||
166 | } never executed: end of block | 0 | ||||||||||||||||||
167 | } | - | ||||||||||||||||||
168 | } | - | ||||||||||||||||||
169 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
170 | - | |||||||||||||||||||
171 | error (0, mkdir_errno, | - | ||||||||||||||||||
172 | dcgettext (((void *)0), | - | ||||||||||||||||||
173 | "cannot create directory %s" | - | ||||||||||||||||||
174 | , 5) | - | ||||||||||||||||||
175 | , quote (dir)); | - | ||||||||||||||||||
176 | return executed 1 time by 1 test: return 0 ; Executed by:
executed 1 time by 1 test: return 0 ; Executed by:
| 1 | ||||||||||||||||||
177 | 0 executed 1 time by 1 test: return 0 ; Executed by:
| 1 | ||||||||||||||||||
178 | ; executed 1 time by 1 test: return 0 ; Executed by:
| 1 | ||||||||||||||||||
179 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |