Changeset 7ab7075f in mainline
- Timestamp:
- 2018-08-06T18:40:12Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1dcba91
- Parents:
- 7afd12e5
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/stdio/stdio2.c
r7afd12e5 r7ab7075f 37 37 { 38 38 FILE *file; 39 const char *file_name = "/t est";39 const char *file_name = "/tmp/test"; 40 40 41 41 TPRINTF("Open file \"%s\" for writing...", file_name); 42 42 errno = 0; 43 file = fopen(file_name, "wt ");43 file = fopen(file_name, "wtx"); 44 44 if (file == NULL) { 45 45 TPRINTF("errno = %s\n", str_error_name(errno)); -
uspace/lib/c/generic/io/io.c
r7afd12e5 r7ab7075f 185 185 } 186 186 187 static bool parse_mode(const char *fmode, int *mode, bool *create, bool *truncate) 187 static bool parse_mode(const char *fmode, int *mode, bool *create, bool *excl, 188 bool *truncate) 188 189 { 189 190 /* Parse mode except first character. */ 190 191 const char *mp = fmode; 191 if (*mp++ == 0) { 192 193 if (*mp++ == '\0') { 192 194 errno = EINVAL; 193 195 return false; … … 201 203 mp++; 202 204 plus = true; 203 } else 205 } else { 204 206 plus = false; 205 206 if (*mp != 0) { 207 } 208 209 bool ex; 210 if (*mp == 'x') { 211 mp++; 212 ex = true; 213 } else { 214 ex = false; 215 } 216 217 if (*mp != '\0') { 207 218 errno = EINVAL; 208 219 return false; … … 211 222 *create = false; 212 223 *truncate = false; 224 *excl = false; 213 225 214 226 /* Parse first character of fmode and determine mode for vfs_open(). */ … … 216 228 case 'r': 217 229 *mode = plus ? MODE_READ | MODE_WRITE : MODE_READ; 230 if (ex) { 231 errno = EINVAL; 232 return false; 233 } 218 234 break; 219 235 case 'w': 220 236 *mode = plus ? MODE_READ | MODE_WRITE : MODE_WRITE; 221 237 *create = true; 238 *excl = ex; 222 239 if (!plus) 223 240 *truncate = true; … … 227 244 if (plus) { 228 245 errno = ENOTSUP; 246 return false; 247 } 248 249 if (ex) { 250 errno = EINVAL; 229 251 return false; 230 252 } … … 307 329 * 308 330 * @param path Path of the file to open. 309 * @param mode Mode string, (r|w|a)[b|t][+] .331 * @param mode Mode string, (r|w|a)[b|t][+][x]. 310 332 * 311 333 */ … … 314 336 int mode; 315 337 bool create; 338 bool excl; 316 339 bool truncate; 317 340 318 if (!parse_mode(fmode, &mode, &create, & truncate))341 if (!parse_mode(fmode, &mode, &create, &excl, &truncate)) 319 342 return NULL; 320 343 … … 327 350 328 351 int flags = WALK_REGULAR; 329 if (create) 352 if (create && excl) 353 flags |= WALK_MUST_CREATE; 354 else if (create) 330 355 flags |= WALK_MAY_CREATE; 331 356 int file; -
uspace/lib/c/test/stdio.c
r7afd12e5 r7ab7075f 62 62 PCUT_ASSERT_TRUE(rc != 0); 63 63 64 f = fopen(buf, "w ");64 f = fopen(buf, "wx"); 65 65 PCUT_ASSERT_NOT_NULL(f); 66 66 fclose(f); … … 92 92 PCUT_ASSERT_NOT_NULL(p); 93 93 94 f = fopen(buf1, "w ");94 f = fopen(buf1, "wx"); 95 95 PCUT_ASSERT_NOT_NULL(f); 96 96 fclose(f); … … 142 142 PCUT_ASSERT_NOT_NULL(p); 143 143 144 f = fopen(p, "w+ ");144 f = fopen(p, "w+x"); 145 145 PCUT_ASSERT_NOT_NULL(f); 146 146 (void) remove(p); … … 174 174 PCUT_ASSERT_NOT_NULL(p); 175 175 176 f = fopen(p, "w+ ");176 f = fopen(p, "w+x"); 177 177 PCUT_ASSERT_NOT_NULL(f); 178 178 (void) remove(p); -
uspace/lib/posix/test/stdio.c
r7afd12e5 r7ab7075f 47 47 str_length("/tmp/tmp.")) == 0); 48 48 49 f = fopen(p, "w+ ");49 f = fopen(p, "w+x"); 50 50 PCUT_ASSERT_NOT_NULL(f); 51 51 … … 66 66 str_length("/tmp/tmp.")) == 0); 67 67 68 f = fopen(p, "w+ ");68 f = fopen(p, "w+x"); 69 69 PCUT_ASSERT_NOT_NULL(f); 70 70 … … 85 85 str_length(P_tmpdir "/tmp.")) == 0); 86 86 87 f = fopen(p, "w+ ");87 f = fopen(p, "w+x"); 88 88 PCUT_ASSERT_NOT_NULL(f); 89 89 -
uspace/lib/sif/src/sif.c
r7afd12e5 r7ab7075f 203 203 } 204 204 205 f = fopen(fname, "w ");205 f = fopen(fname, "wx"); 206 206 if (f == NULL) { 207 207 rc = EIO;
Note:
See TracChangeset
for help on using the changeset viewer.