fd-util: add helper for converting O_RDONLY/WRONLY/RDWR to strings

This commit is contained in:
Lennart Poettering
2023-03-29 18:27:05 +02:00
parent d80e2a1ed3
commit b2b84f4b23
2 changed files with 15 additions and 0 deletions
+13
View File
@@ -935,3 +935,16 @@ int dir_fd_is_root(int dir_fd) {
*/
return statx_inode_same(&st.sx, &pst.sx) && statx_mount_same(&st.nsx, &pst.nsx);
}
const char *accmode_to_string(int flags) {
switch (flags & O_ACCMODE) {
case O_RDONLY:
return "ro";
case O_WRONLY:
return "wo";
case O_RDWR:
return "rw";
default:
return NULL;
}
}