fs-util: add comment explaining what xopenat() is for

This commit is contained in:
Lennart Poettering
2023-11-23 02:29:37 +09:00
committed by Yu Watanabe
parent 3197d778e0
commit 9b85e90780
2 changed files with 13 additions and 0 deletions
+10
View File
@@ -1113,6 +1113,16 @@ int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
/* This is like openat(), but has a few tricks up its sleeves, extending behaviour:
*
* • O_DIRECTORY|O_CREAT is supported, which causes a directory to be created, and immediately
* opened. When used with the XO_SUBVOLUME flag this will even create a btrfs subvolume.
*
* • If O_CREAT is used with XO_LABEL, any created file will be immediately relabelled.
*
* • If the path is specified NULL or empty, behaves like fd_reopen().
*/
if (isempty(path)) {
assert(!FLAGS_SET(open_flags, O_CREAT|O_EXCL));
return fd_reopen(dir_fd, open_flags & ~O_NOFOLLOW);