1 /* 2 * Copyright 2002-2008, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _FSSH_SYS_STAT_H_ 6 #define _FSSH_SYS_STAT_H_ 7 8 9 #include "fssh_defs.h" 10 #include "fssh_time.h" 11 12 13 struct fssh_stat { 14 fssh_dev_t fssh_st_dev; /* "device" that this file resides on */ 15 fssh_ino_t fssh_st_ino; /* this file's inode #, unique per device */ 16 fssh_mode_t fssh_st_mode; /* mode bits (rwx for user, group, etc) */ 17 fssh_nlink_t fssh_st_nlink; /* number of hard links to this file */ 18 fssh_uid_t fssh_st_uid; /* user id of the owner of this file */ 19 fssh_gid_t fssh_st_gid; /* group id of the owner of this file */ 20 fssh_off_t fssh_st_size; /* size in bytes of this file */ 21 fssh_dev_t fssh_st_rdev; /* device type (not used) */ 22 fssh_size_t fssh_st_blksize; /* preferred block size for i/o */ 23 fssh_time_t fssh_st_atime; /* last access time */ 24 fssh_time_t fssh_st_mtime; /* last modification time */ 25 fssh_time_t fssh_st_ctime; /* last change time, not creation time */ 26 fssh_time_t fssh_st_crtime; /* creation time */ 27 28 // Haiku extensions: 29 // TODO: we might also define special types for files and TTYs 30 // TODO: we should find another solution for this, as BStatable::GetStat() 31 // can only retrieve the R5 stat structure 32 unsigned int fssh_st_type; /* attribute/index type */ 33 }; 34 typedef struct fssh_stat fssh_struct_stat; 35 36 /* extended file types */ 37 #define FSSH_S_ATTR_DIR 01000000000 /* attribute directory */ 38 #define FSSH_S_ATTR 02000000000 /* attribute */ 39 #define FSSH_S_INDEX_DIR 04000000000 /* index (or index directory) */ 40 #define FSSH_S_STR_INDEX 00100000000 /* string index */ 41 #define FSSH_S_INT_INDEX 00200000000 /* int32 index */ 42 #define FSSH_S_UINT_INDEX 00400000000 /* uint32 index */ 43 #define FSSH_S_LONG_LONG_INDEX 00010000000 /* int64 index */ 44 #define FSSH_S_ULONG_LONG_INDEX 00020000000 /* uint64 index */ 45 #define FSSH_S_FLOAT_INDEX 00040000000 /* float index */ 46 #define FSSH_S_DOUBLE_INDEX 00001000000 /* double index */ 47 #define FSSH_S_ALLOW_DUPS 00002000000 /* allow duplicate entries (currently unused) */ 48 49 /* link types */ 50 #define FSSH_S_LINK_SELF_HEALING 00001000000 /* link will be updated if you move its target */ 51 #define FSSH_S_LINK_AUTO_DELETE 00002000000 /* link will be deleted if you delete its target */ 52 53 /* standard file types */ 54 #define FSSH_S_IFMT 00000170000 /* type of file */ 55 #define FSSH_S_IFLNK 00000120000 /* symbolic link */ 56 #define FSSH_S_IFREG 00000100000 /* regular */ 57 #define FSSH_S_IFBLK 00000060000 /* block special */ 58 #define FSSH_S_IFDIR 00000040000 /* directory */ 59 #define FSSH_S_IFCHR 00000020000 /* character special */ 60 #define FSSH_S_IFIFO 00000010000 /* fifo */ 61 62 #define FSSH_S_ISREG(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFREG) 63 #define FSSH_S_ISLNK(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFLNK) 64 #define FSSH_S_ISBLK(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFBLK) 65 #define FSSH_S_ISDIR(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFDIR) 66 #define FSSH_S_ISCHR(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFCHR) 67 #define FSSH_S_ISFIFO(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFIFO) 68 #define FSSH_S_ISINDEX(mode) (((mode) & FSSH_S_INDEX_DIR) == FSSH_S_INDEX_DIR) 69 70 #define FSSH_S_IUMSK 07777 /* user settable bits */ 71 72 #define FSSH_S_ISUID 04000 /* set user id on execution */ 73 #define FSSH_S_ISGID 02000 /* set group id on execution */ 74 75 #define FSSH_S_ISVTX 01000 /* save swapped text even after use (sticky bit) */ 76 77 #define FSSH_S_IRWXU 00700 /* read, write, execute: owner */ 78 #define FSSH_S_IRUSR 00400 /* read permission: owner */ 79 #define FSSH_S_IWUSR 00200 /* write permission: owner */ 80 #define FSSH_S_IXUSR 00100 /* execute permission: owner */ 81 #define FSSH_S_IRWXG 00070 /* read, write, execute: group */ 82 #define FSSH_S_IRGRP 00040 /* read permission: group */ 83 #define FSSH_S_IWGRP 00020 /* write permission: group */ 84 #define FSSH_S_IXGRP 00010 /* execute permission: group */ 85 #define FSSH_S_IRWXO 00007 /* read, write, execute: other */ 86 #define FSSH_S_IROTH 00004 /* read permission: other */ 87 #define FSSH_S_IWOTH 00002 /* write permission: other */ 88 #define FSSH_S_IXOTH 00001 /* execute permission: other */ 89 90 #define FSSH_ACCESSPERMS (FSSH_S_IRWXU | FSSH_S_IRWXG | FSSH_S_IRWXO) 91 #define FSSH_ALLPERMS (FSSH_S_ISUID | FSSH_S_ISGID | FSSH_S_ISVTX \ 92 | FSSH_S_IRWXU | FSSH_S_IRWXG | FSSH_S_IRWXO) 93 #define FSSH_DEFFILEMODE (FSSH_S_IRUSR | FSSH_S_IWUSR | FSSH_S_IRGRP \ 94 | FSSH_S_IWGRP | FSSH_S_IROTH | FSSH_S_IWOTH) 95 /* default file mode, everyone can read/write */ 96 97 #ifdef __cplusplus 98 extern "C" { 99 #endif 100 101 extern int fssh_chmod(const char *path, fssh_mode_t mode); 102 extern int fssh_fchmod(int fd, fssh_mode_t mode); 103 extern int fssh_mkdir(const char *path, fssh_mode_t mode); 104 extern int fssh_mkfifo(const char *path, fssh_mode_t mode); 105 extern fssh_mode_t fssh_umask(fssh_mode_t cmask); 106 107 extern int fssh_stat(const char *path, struct fssh_stat *st); 108 extern int fssh_fstat(int fd, struct fssh_stat *st); 109 extern int fssh_lstat(const char *path, struct fssh_stat *st); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif /* _FSSH_SYS_STAT_H_ */ 116