Skip to content

Commit 9b85e90

Browse files
poetteringyuwata
authored andcommitted
fs-util: add comment explaining what xopenat() is for
1 parent 3197d77 commit 9b85e90

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

TODO

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ Janitorial Clean-ups:
8989
this up, and should probably always apply both, i.e. introduce
9090
unit_file_escape() or so, which applies both.
9191

92+
* xopenat() should pin the parent dir of the inode it creates before doing its
93+
thing, so that it can create, open, label somewhat atomically.
94+
9295
Deprecations and removals:
9396

9497
* Remove any support for booting without /usr pre-mounted in the initrd entirely.

src/basic/fs-util.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,16 @@ int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags
11131113

11141114
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
11151115

1116+
/* This is like openat(), but has a few tricks up its sleeves, extending behaviour:
1117+
*
1118+
* • O_DIRECTORY|O_CREAT is supported, which causes a directory to be created, and immediately
1119+
* opened. When used with the XO_SUBVOLUME flag this will even create a btrfs subvolume.
1120+
*
1121+
* • If O_CREAT is used with XO_LABEL, any created file will be immediately relabelled.
1122+
*
1123+
* • If the path is specified NULL or empty, behaves like fd_reopen().
1124+
*/
1125+
11161126
if (isempty(path)) {
11171127
assert(!FLAGS_SET(open_flags, O_CREAT|O_EXCL));
11181128
return fd_reopen(dir_fd, open_flags & ~O_NOFOLLOW);

0 commit comments

Comments
 (0)