🎭 Linux Open Flags Calculator


Enter flags:

Result:


All Flags:

What is it for?

This calculator is for decoding open file creation flags and file status flags in to a human-readable format. It will be probably be useless to 99.99999% of people. These flags are defined here: /include/uapi/asm-generic/fcntl.h (and probably somewhere else also) They defined what access we have to a path. They appear in open(), and openat() system calls.
    int open(const char *pathname, int flags);
    int open(const char *pathname, int flags, mode_t mode);

    int openat(int dirfd, const char *pathname, int flags);
    int openat(int dirfd, const char *pathname, int flags, mode_t mode);

For example we have:
int fd = open("/tmp/test.txt", O_RDWR|O_CREAT);

They are defined here: https://man7.org/linux/man-pages/man2/open.2.html They are used in the inode struct and the file struct:
struct inode {
    struct hlist_node       i_hash;           /* hash list */
    struct list_head        i_list;           /* list of inodes */
    struct list_head        i_dentry;         /* list of dentries */
    unsigned long           i_ino;            /* inode number */
    [SNIPPED]
    unsigned int            i_flags;          /* filesystem flags */

struct file {
    struct list_head        f_list;
    struct dentry           *f_dentry;
    [SNIPPED]
    unsigned int            f_flags;        

f_flags in file struct: O_XXX flags from open(2) system call copied there (with slight modifications by filp_open()) by dentry_open() and after clearing O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC - there is no point in storing these flags permanently since they cannot be modified by F_SETFL (or queried by F_GETFL) fcntl(2) calls. (Source: https://tldp.org/LDP/lki/lki-3.html)