11da177e4SLinus Torvalds #ifndef __UM_FS_HOSTFS 21da177e4SLinus Torvalds #define __UM_FS_HOSTFS 31da177e4SLinus Torvalds 41da177e4SLinus Torvalds #include "os.h" 51da177e4SLinus Torvalds 684b3db04SJeff Dike /* 784b3db04SJeff Dike * These are exactly the same definitions as in fs.h, but the names are 81da177e4SLinus Torvalds * changed so that this file can be included in both kernel and user files. 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds #define HOSTFS_ATTR_MODE 1 121da177e4SLinus Torvalds #define HOSTFS_ATTR_UID 2 131da177e4SLinus Torvalds #define HOSTFS_ATTR_GID 4 141da177e4SLinus Torvalds #define HOSTFS_ATTR_SIZE 8 151da177e4SLinus Torvalds #define HOSTFS_ATTR_ATIME 16 161da177e4SLinus Torvalds #define HOSTFS_ATTR_MTIME 32 171da177e4SLinus Torvalds #define HOSTFS_ATTR_CTIME 64 181da177e4SLinus Torvalds #define HOSTFS_ATTR_ATIME_SET 128 191da177e4SLinus Torvalds #define HOSTFS_ATTR_MTIME_SET 256 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds /* These two are unused by hostfs. */ 221da177e4SLinus Torvalds #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */ 231da177e4SLinus Torvalds #define HOSTFS_ATTR_ATTR_FLAG 1024 241da177e4SLinus Torvalds 2584b3db04SJeff Dike /* 2684b3db04SJeff Dike * If you are very careful, you'll notice that these two are missing: 271da177e4SLinus Torvalds * 281da177e4SLinus Torvalds * #define ATTR_KILL_SUID 2048 291da177e4SLinus Torvalds * #define ATTR_KILL_SGID 4096 301da177e4SLinus Torvalds * 31631dd1a8SJustin P. Mattock * and this is because they were added in 2.5 development. 321da177e4SLinus Torvalds * Actually, they are not needed by most ->setattr() methods - they are set by 331da177e4SLinus Torvalds * callers of notify_change() to notify that the setuid/setgid bits must be 341da177e4SLinus Torvalds * dropped. 351da177e4SLinus Torvalds * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE 361da177e4SLinus Torvalds * is on, and remove the appropriate bits from attr->ia_mode (attr is a 371da177e4SLinus Torvalds * "struct iattr *"). -BlaisorBlade 381da177e4SLinus Torvalds */ 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds struct hostfs_iattr { 411da177e4SLinus Torvalds unsigned int ia_valid; 42138d570dSAl Viro unsigned short ia_mode; 431da177e4SLinus Torvalds uid_t ia_uid; 441da177e4SLinus Torvalds gid_t ia_gid; 451da177e4SLinus Torvalds loff_t ia_size; 461da177e4SLinus Torvalds struct timespec ia_atime; 471da177e4SLinus Torvalds struct timespec ia_mtime; 481da177e4SLinus Torvalds struct timespec ia_ctime; 491da177e4SLinus Torvalds }; 501da177e4SLinus Torvalds 5139b743c6SAl Viro struct hostfs_stat { 5239b743c6SAl Viro unsigned long long ino; 5339b743c6SAl Viro unsigned int mode; 5439b743c6SAl Viro unsigned int nlink; 5539b743c6SAl Viro unsigned int uid; 5639b743c6SAl Viro unsigned int gid; 5739b743c6SAl Viro unsigned long long size; 5839b743c6SAl Viro struct timespec atime, mtime, ctime; 5939b743c6SAl Viro unsigned int blksize; 6039b743c6SAl Viro unsigned long long blocks; 6139b743c6SAl Viro unsigned int maj; 6239b743c6SAl Viro unsigned int min; 6339b743c6SAl Viro }; 6439b743c6SAl Viro 6539b743c6SAl Viro extern int stat_file(const char *path, struct hostfs_stat *p, int fd); 661da177e4SLinus Torvalds extern int access_file(char *path, int r, int w, int x); 671da177e4SLinus Torvalds extern int open_file(char *path, int r, int w, int append); 681da177e4SLinus Torvalds extern void *open_dir(char *path, int *err_out); 691da177e4SLinus Torvalds extern char *read_dir(void *stream, unsigned long long *pos, 70*3ee6bd8eSGeert Uytterhoeven unsigned long long *ino_out, int *len_out, 71*3ee6bd8eSGeert Uytterhoeven unsigned int *type_out); 721da177e4SLinus Torvalds extern void close_file(void *stream); 73f8ad850fSAl Viro extern int replace_file(int oldfd, int fd); 741da177e4SLinus Torvalds extern void close_dir(void *stream); 751da177e4SLinus Torvalds extern int read_file(int fd, unsigned long long *offset, char *buf, int len); 761da177e4SLinus Torvalds extern int write_file(int fd, unsigned long long *offset, const char *buf, 771da177e4SLinus Torvalds int len); 781da177e4SLinus Torvalds extern int lseek_file(int fd, long long offset, int whence); 79a2d76bd8SPaolo 'Blaisorblade' Giarrusso extern int fsync_file(int fd, int datasync); 801da177e4SLinus Torvalds extern int file_create(char *name, int ur, int uw, int ux, int gr, 811da177e4SLinus Torvalds int gw, int gx, int or, int ow, int ox); 825822b7faSAlberto Bertogli extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd); 831da177e4SLinus Torvalds extern int make_symlink(const char *from, const char *to); 841da177e4SLinus Torvalds extern int unlink_file(const char *file); 851da177e4SLinus Torvalds extern int do_mkdir(const char *file, int mode); 861da177e4SLinus Torvalds extern int do_rmdir(const char *file); 8784b3db04SJeff Dike extern int do_mknod(const char *file, int mode, unsigned int major, 8884b3db04SJeff Dike unsigned int minor); 891da177e4SLinus Torvalds extern int link_file(const char *from, const char *to); 90ea7e743eSWANG Cong extern int hostfs_do_readlink(char *file, char *buf, int size); 911da177e4SLinus Torvalds extern int rename_file(char *from, char *to); 921da177e4SLinus Torvalds extern int do_statfs(char *root, long *bsize_out, long long *blocks_out, 931da177e4SLinus Torvalds long long *bfree_out, long long *bavail_out, 941da177e4SLinus Torvalds long long *files_out, long long *ffree_out, 951b627d57SRichard Weinberger void *fsid_out, int fsid_size, long *namelen_out); 961da177e4SLinus Torvalds 971da177e4SLinus Torvalds #endif 98