Changeset 8565a42 in mainline for uspace/lib/posix/src/stdlib.c
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/src/stdlib.c
r3061bc1 r8565a42 165 165 } 166 166 } 167 167 168 168 return NULL; 169 169 } … … 225 225 assert(resolved == NULL); 226 226 #endif 227 227 228 228 if (name == NULL) { 229 229 errno = EINVAL; 230 230 return NULL; 231 231 } 232 232 233 233 // TODO: symlink resolution 234 234 235 235 /* Function absolutize is implemented in libc and declared in vfs.h. 236 236 * No more processing is required as HelenOS doesn't have symlinks … … 239 239 */ 240 240 char* absolute = vfs_absolutize(name, NULL); 241 241 242 242 if (absolute == NULL) { 243 243 /* POSIX requires some specific errnos to be set … … 248 248 return NULL; 249 249 } 250 250 251 251 if (resolved == NULL) { 252 252 return absolute; … … 309 309 { 310 310 int fd = -1; 311 311 312 312 char *tptr = tmpl + strlen(tmpl) - 6; 313 313 314 314 while (fd < 0) { 315 315 if (*mktemp(tmpl) == '\0') { … … 317 317 return -1; 318 318 } 319 319 320 320 fd = open(tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); 321 321 322 322 if (fd == -1) { 323 323 /* Restore template to it's original state. */ … … 325 325 } 326 326 } 327 327 328 328 return fd; 329 329 } … … 345 345 return tmpl; 346 346 } 347 347 348 348 char *tptr = tmpl + tmpl_len - 6; 349 349 if (strcmp(tptr, "XXXXXX") != 0) { … … 352 352 return tmpl; 353 353 } 354 354 355 355 static int seq = 0; 356 356 357 357 for (; seq < 1000000; ++seq) { 358 358 snprintf(tptr, 7, "%06d", seq); 359 359 360 360 int orig_errno = errno; 361 361 errno = 0; … … 372 372 } 373 373 } 374 374 375 375 if (seq == 10000000) { 376 376 errno = EEXIST; … … 378 378 return tmpl; 379 379 } 380 380 381 381 return tmpl; 382 382 } … … 392 392 { 393 393 assert(nelem > 0); 394 394 395 395 size_t count; 396 396 load_t *loads = stats_get_load(&count); 397 397 398 398 if (loads == NULL) { 399 399 return -1; 400 400 } 401 401 402 402 if (((size_t) nelem) < count) { 403 403 count = nelem; 404 404 } 405 405 406 406 for (size_t i = 0; i < count; ++i) { 407 407 loadavg[i] = (double) loads[i]; 408 408 } 409 409 410 410 free(loads); 411 411 return count;
Note:
See TracChangeset
for help on using the changeset viewer.