カーネル:root/include/uapi/linux/stat.h
先頭0は3ビットの8進数010 = 8
#define S_IFMT 00170000 => 15=0b1111:S_IFSOCK[1100]~S_IFIFO[0001]のファイル名称に係るビット領域
#define S_IFSOCK 0140000
#define S_IFLNK 0120000
#define S_IFREG 0100000
#define S_IFBLK 0060000
#define S_IFDIR 0040000
#define S_IFCHR 0020000
#define S_IFIFO 0010000
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
1バイト 8ビット
typedef unsigned short[システムに関わりなく2バイト] umode_t;
umode_t inode->i_mode [1バイト8ビット:2×8=16ビット]
4ビット->ファイル名称 :S_IFSOCK/S_IFLNK/S_IFREG/S_IFBLK/S_IFDIR/S_IFCHR/S_IFIFO
3ビット->Stick :S_ISUID/S_ISGID/S_ISVTX
3ビット->User :S_IRUSR/S_IWUSR/S_IXUSR
3ビット->Group :S_IRGRP/S_IWGRP/S_IXGRP
3ビット->Other :S_IROTH/S_IWOTH/S_IXOTH
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
捕捉
[root@north dir]# cat octal.c
#include <stdio.h>
void main(void)
{
printf("10進数 11=%2d\n", 11);
printf(" 8進数 011=%2d\n", 011);
}
[root@north dir]# ./octal.out
10進数 11=11
8進数 011= 9
備考
user/grop/otherのrwx属性に係る属性でないのに、lsコマンドのスティッキービットは、大文字小文字によるuser/grop/otherの実行属性に係る実装で、xs属性はS x属性はx s属性はs
係る確認は通常業務で頻繁に設定することはない故、s/S属性の違いに戸惑ってしまって、こんな実装でなく、スティッキービット表示領域としするsssとの表示すべきえはと。
[root@A0-F3-C1-17-02-A8 dir]# chmod ug-x cmd.out
[root@A0-F3-C1-17-02-A8 dir]# ls -l cmd.out
-rw----r-x 1 root root 7560 3月 9 14:36 cmd.out
[root@A0-F3-C1-17-02-A8 dir]# chmod ug+s cmd.out
[root@A0-F3-C1-17-02-A8 dir]# ls -l cmd.out
-rwS--Sr-x 1 root root 7560 3月 9 14:36 cmd.out <xでないsはS
[root@A0-F3-C1-17-02-A8 dir]# chmod ug+x cmd.out
[root@A0-F3-C1-17-02-A8 dir]# ls -l cmd.out
-rws--sr-x 1 root root 7560 3月 9 14:36 cmd.out <xでのsはs
struct inode {
umode_t i_mode;
unsigned short i_opflags;
kuid_t i_uid;
kgid_t i_gid;
unsigned int i_flags;
#ifdef CONFIG_FS_POSIX_ACL
struct posix_acl *i_acl;
struct posix_acl *i_default_acl;
#endif
const struct inode_operations *i_op;
struct super_block *i_sb;
struct address_space *i_mapping;
#ifdef CONFIG_SECURITY
void *i_security;
#endif
unsigned long i_ino;
union {
const unsigned int i_nlink;
unsigned int __i_nlink;
};
dev_t i_rdev;
loff_t i_size;
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
unsigned short i_bytes;
unsigned int i_blkbits;
blkcnt_t i_blocks;
#ifdef __NEED_I_SIZE_ORDERED
seqcount_t i_size_seqcount;
#endif
unsigned long i_state;
struct mutex i_mutex;
unsigned long dirtied_when; /* jiffies of first dirtying */
struct hlist_node i_hash;
struct list_head i_wb_list; /* backing dev IO list */
struct list_head i_lru; /* inode LRU list */
struct list_head i_sb_list;
union {
struct hlist_head i_dentry;
struct rcu_head i_rcu;
};
u64 i_version;
atomic_t i_count;
atomic_t i_dio_count;
atomic_t i_writecount;
const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
struct file_lock *i_flock;
struct address_space i_data;
#ifdef CONFIG_QUOTA
struct dquot *i_dquot[MAXQUOTAS];
#endif
struct list_head i_devices;
union {
struct pipe_inode_info *i_pipe;
struct block_device *i_bdev;
struct cdev *i_cdev;
};
__u32 i_generation;
#ifdef CONFIG_FSNOTIFY
__u32 i_fsnotify_mask; /* all events this inode cares about */
struct hlist_head i_fsnotify_marks;
#endif
#ifdef CONFIG_IMA
atomic_t i_readcount; /* struct files open RO */
#endif
void *i_private; /* fs or device private pointer */
};