opendir2.c (c08e019c6ce4fc637b195f1bb0878763c3fefe9e) | opendir2.c (dd81cc2bc5f25fb2c58bb59bf585deeeae196345) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1983, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 301 unchanged lines hidden (view full) --- 310 if (use_current_pos) { 311 /* 312 * Read the first batch of directory entries 313 * to prime dd_seek. This also checks if the 314 * fd passed to fdopendir() is a directory. 315 */ 316 dirp->dd_size = _getdirentries(dirp->dd_fd, 317 dirp->dd_buf, dirp->dd_len, &dirp->dd_seek); | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1983, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 301 unchanged lines hidden (view full) --- 310 if (use_current_pos) { 311 /* 312 * Read the first batch of directory entries 313 * to prime dd_seek. This also checks if the 314 * fd passed to fdopendir() is a directory. 315 */ 316 dirp->dd_size = _getdirentries(dirp->dd_fd, 317 dirp->dd_buf, dirp->dd_len, &dirp->dd_seek); |
318 if (dirp->dd_size < 0) { 319 if (errno == EINVAL) 320 errno = ENOTDIR; | 318 if (dirp->dd_size < 0) |
321 goto fail; | 319 goto fail; |
322 } | |
323 dirp->dd_flags |= __DTF_SKIPREAD; 324 } else { 325 dirp->dd_size = 0; 326 dirp->dd_seek = 0; 327 } 328 } 329 330 return (dirp); 331 332fail: 333 saved_errno = errno; 334 free(dirp->dd_buf); 335 free(dirp); 336 errno = saved_errno; 337 return (NULL); 338} | 320 dirp->dd_flags |= __DTF_SKIPREAD; 321 } else { 322 dirp->dd_size = 0; 323 dirp->dd_seek = 0; 324 } 325 } 326 327 return (dirp); 328 329fail: 330 saved_errno = errno; 331 free(dirp->dd_buf); 332 free(dirp); 333 errno = saved_errno; 334 return (NULL); 335} |