It's a good question. If path_name is absolute, the file descriptor is ignored. I used -1 (EBADF) instead of AT_FDCWD there so if a non-absolute path gets in there it errors out instead of attempting to use a relative path off the current directory.
I'm not entirely sure if it's the best way, so if anyone else has ideas let me know. On Fri, Apr 24, 2015 at 11:24 AM, David Sterba <dste...@suse.cz> wrote: > On Thu, Apr 23, 2015 at 12:51:33PM -0400, Dan Merillat wrote: >> +/* returns: >> + * 0 if the file exists and should be skipped. >> + * 1 if the file does NOT exist >> + * 2 if the file exists but is OK to overwrite >> + */ >> + >> +static int overwrite_ok(const char * path) >> +{ >> + static int warn = 0; >> + struct stat st; >> + int ret; >> + >> + /* don't be fooled by symlinks */ >> + ret = fstatat(-1, path_name, &st, AT_SYMLINK_NOFOLLOW); > > Is the filedescriptor -1 correct? Previously, stat was used that uses > AT_FDCWD for the dirfd, which is -100. -1 could be intepreted as a bad > filedescriptor (EBADF). -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html