1/* 2 * Copyright 2002-2009, 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 13struct 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_timespec fssh_st_atim; /* last access time */ 24 fssh_timespec fssh_st_mtim; /* last modification time */ 25 fssh_timespec fssh_st_ctim; /* last change time, not creation time */ 26 fssh_timespec fssh_st_crtim; /* 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 fssh_off_t fssh_st_blocks; /* number of blocks allocated for object */ 34}; 35typedef struct fssh_stat fssh_struct_stat; 36 37/* compatibility with older apps */ 38#define fssh_st_atime fssh_st_atim.tv_sec 39#define fssh_st_mtime fssh_st_mtim.tv_sec 40#define fssh_st_ctime fssh_st_ctim.tv_sec 41#define fssh_st_crtime fssh_st_crtim.tv_sec 42 43/* extended file types */ 44#define FSSH_S_ATTR_DIR 01000000000 /* attribute directory */ 45#define FSSH_S_ATTR 02000000000 /* attribute */ 46#define FSSH_S_INDEX_DIR 04000000000 /* index (or index directory) */ 47#define FSSH_S_STR_INDEX 00100000000 /* string index */ 48#define FSSH_S_INT_INDEX 00200000000 /* int32 index */ 49#define FSSH_S_UINT_INDEX 00400000000 /* uint32 index */ 50#define FSSH_S_LONG_LONG_INDEX 00010000000 /* int64 index */ 51#define FSSH_S_ULONG_LONG_INDEX 00020000000 /* uint64 index */ 52#define FSSH_S_FLOAT_INDEX 00040000000 /* float index */ 53#define FSSH_S_DOUBLE_INDEX 00001000000 /* double index */ 54#define FSSH_S_ALLOW_DUPS 00002000000 /* allow duplicate entries (currently unused) */ 55 56/* link types */ 57#define FSSH_S_LINK_SELF_HEALING 00001000000 /* link will be updated if you move its target */ 58#define FSSH_S_LINK_AUTO_DELETE 00002000000 /* link will be deleted if you delete its target */ 59 60/* standard file types */ 61#define FSSH_S_IFMT 00000170000 /* type of file */ 62#define FSSH_S_IFSOCK 00000140000 /* socket */ 63#define FSSH_S_IFLNK 00000120000 /* symbolic link */ 64#define FSSH_S_IFREG 00000100000 /* regular */ 65#define FSSH_S_IFBLK 00000060000 /* block special */ 66#define FSSH_S_IFDIR 00000040000 /* directory */ 67#define FSSH_S_IFCHR 00000020000 /* character special */ 68#define FSSH_S_IFIFO 00000010000 /* fifo */ 69 70#define FSSH_S_ISREG(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFREG) 71#define FSSH_S_ISLNK(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFLNK) 72#define FSSH_S_ISBLK(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFBLK) 73#define FSSH_S_ISDIR(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFDIR) 74#define FSSH_S_ISCHR(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFCHR) 75#define FSSH_S_ISFIFO(mode) (((mode) & FSSH_S_IFMT) == FSSH_S_IFIFO) 76#define FSSH_S_ISINDEX(mode) (((mode) & FSSH_S_INDEX_DIR) == FSSH_S_INDEX_DIR) 77 78#define FSSH_S_IUMSK 07777 /* user settable bits */ 79 80#define FSSH_S_ISUID 04000 /* set user id on execution */ 81#define FSSH_S_ISGID 02000 /* set group id on execution */ 82 83#define FSSH_S_ISVTX 01000 /* save swapped text even after use (sticky bit) */ 84 85#define FSSH_S_IRWXU 00700 /* read, write, execute: owner */ 86#define FSSH_S_IRUSR 00400 /* read permission: owner */ 87#define FSSH_S_IWUSR 00200 /* write permission: owner */ 88#define FSSH_S_IXUSR 00100 /* execute permission: owner */ 89#define FSSH_S_IRWXG 00070 /* read, write, execute: group */ 90#define FSSH_S_IRGRP 00040 /* read permission: group */ 91#define FSSH_S_IWGRP 00020 /* write permission: group */ 92#define FSSH_S_IXGRP 00010 /* execute permission: group */ 93#define FSSH_S_IRWXO 00007 /* read, write, execute: other */ 94#define FSSH_S_IROTH 00004 /* read permission: other */ 95#define FSSH_S_IWOTH 00002 /* write permission: other */ 96#define FSSH_S_IXOTH 00001 /* execute permission: other */ 97 98#define FSSH_ACCESSPERMS (FSSH_S_IRWXU | FSSH_S_IRWXG | FSSH_S_IRWXO) 99#define FSSH_ALLPERMS (FSSH_S_ISUID | FSSH_S_ISGID | FSSH_S_ISVTX \ 100 | FSSH_S_IRWXU | FSSH_S_IRWXG | FSSH_S_IRWXO) 101#define FSSH_DEFFILEMODE (FSSH_S_IRUSR | FSSH_S_IWUSR | FSSH_S_IRGRP \ 102 | FSSH_S_IWGRP | FSSH_S_IROTH | FSSH_S_IWOTH) 103 /* default file mode, everyone can read/write */ 104 105#ifdef __cplusplus 106extern "C" { 107#endif 108 109extern int fssh_chmod(const char *path, fssh_mode_t mode); 110extern int fssh_fchmod(int fd, fssh_mode_t mode); 111extern int fssh_mkdir(const char *path, fssh_mode_t mode); 112extern int fssh_mkfifo(const char *path, fssh_mode_t mode); 113extern fssh_mode_t fssh_umask(fssh_mode_t cmask); 114 115extern int fssh_stat(const char *path, struct fssh_stat *st); 116extern int fssh_fstat(int fd, struct fssh_stat *st); 117extern int fssh_lstat(const char *path, struct fssh_stat *st); 118 119#ifdef __cplusplus 120} 121#endif 122 123#endif /* _FSSH_SYS_STAT_H_ */ 124