Oleg Drokin wrote: > Also it adds AT_STAT_SELF flag to mean that the stat should be > executed not on a path, but on the passed filedecriptor itself. Ok. See below. > Jamie Lokier wrote: >> ret = fstatat(fd, 0, &stat, AT_STAT_TYPE|AT_STAT_SIZE); >> Where 0 in the path automatically means AT_STAT_SELF. >> Or this? >> ret = fstatat(fd, AT_STAT_SELF, &stat, AT_STAT_TYPE|AT_STAT_SIZE); >> Where AT_STAT_SELF is defined as (const char *)-1 in system headers, >> to better catch null pointer application bugs. > > While I think the last one might be attractive, we also need to think > about compatibility, unaware kernels would return -EFAULT if you pass > some nonsense as a path, which is much less useful than say nice EINVAL. About compatibility, you might look at this in "man utimensat": On Linux, futimens() is a library function implemented on top of the utimensat() system call. To support this, the Linux utimensat() system call implements a non-standard feature: if pathname is NULL, then the call modifies the timestamps of the file referred to by the file descriptor dirfd (which may refer to any type of file). Using this feature, the call futimens(fd, times) is implemented as: utimensat(fd, NULL, times, 0); It's inconsistent to have AT_STAT_SELF for the stat-light call, but NULL path for the utimensat() call (system call; Glibc hides it) to mean the same thing, which is act on the passed file descriptor. I think your scheme is better :-) And safer when an application passes NULL due to programming eror. But it is inconsistent. It would be nice if they weren't, or if they used a common flag, in the same way that other flags like AT_SYMLINK_NOFOLLOW have the same meaning for all the *at() calls. Then again, the *at() system calls are somewhat inconsistent anyway. fchmodat() doesn't accept AT_SYMLINK_NOFOLLOW according to the man page I have here. -- Jamie -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html