Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef __UM_FS_HOSTFS |
| 3 | #define __UM_FS_HOSTFS |
| 4 | |
Al Viro | 37185b3 | 2012-10-08 03:27:32 +0100 | [diff] [blame] | 5 | #include <os.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Jeff Dike | 84b3db0 | 2007-10-16 01:27:13 -0700 | [diff] [blame] | 7 | /* |
| 8 | * These are exactly the same definitions as in fs.h, but the names are |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * changed so that this file can be included in both kernel and user files. |
| 10 | */ |
| 11 | |
| 12 | #define HOSTFS_ATTR_MODE 1 |
| 13 | #define HOSTFS_ATTR_UID 2 |
| 14 | #define HOSTFS_ATTR_GID 4 |
| 15 | #define HOSTFS_ATTR_SIZE 8 |
| 16 | #define HOSTFS_ATTR_ATIME 16 |
| 17 | #define HOSTFS_ATTR_MTIME 32 |
| 18 | #define HOSTFS_ATTR_CTIME 64 |
| 19 | #define HOSTFS_ATTR_ATIME_SET 128 |
| 20 | #define HOSTFS_ATTR_MTIME_SET 256 |
| 21 | |
NeilBrown | 4cdfffc | 2018-08-17 15:44:37 -0700 | [diff] [blame] | 22 | /* This one is unused by hostfs. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */ |
| 24 | #define HOSTFS_ATTR_ATTR_FLAG 1024 |
| 25 | |
Jeff Dike | 84b3db0 | 2007-10-16 01:27:13 -0700 | [diff] [blame] | 26 | /* |
| 27 | * If you are very careful, you'll notice that these two are missing: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | * |
| 29 | * #define ATTR_KILL_SUID 2048 |
| 30 | * #define ATTR_KILL_SGID 4096 |
| 31 | * |
Justin P. Mattock | 631dd1a | 2010-10-18 11:03:14 +0200 | [diff] [blame] | 32 | * and this is because they were added in 2.5 development. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | * Actually, they are not needed by most ->setattr() methods - they are set by |
| 34 | * callers of notify_change() to notify that the setuid/setgid bits must be |
| 35 | * dropped. |
| 36 | * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE |
| 37 | * is on, and remove the appropriate bits from attr->ia_mode (attr is a |
| 38 | * "struct iattr *"). -BlaisorBlade |
| 39 | */ |
Arnd Bergmann | bca3026 | 2018-06-12 15:31:17 +0200 | [diff] [blame] | 40 | struct hostfs_timespec { |
| 41 | long long tv_sec; |
| 42 | long long tv_nsec; |
| 43 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | struct hostfs_iattr { |
Arnd Bergmann | bca3026 | 2018-06-12 15:31:17 +0200 | [diff] [blame] | 46 | unsigned int ia_valid; |
| 47 | unsigned short ia_mode; |
| 48 | uid_t ia_uid; |
| 49 | gid_t ia_gid; |
| 50 | loff_t ia_size; |
| 51 | struct hostfs_timespec ia_atime; |
| 52 | struct hostfs_timespec ia_mtime; |
| 53 | struct hostfs_timespec ia_ctime; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Al Viro | 39b743c | 2010-06-06 20:08:56 -0400 | [diff] [blame] | 56 | struct hostfs_stat { |
| 57 | unsigned long long ino; |
| 58 | unsigned int mode; |
| 59 | unsigned int nlink; |
| 60 | unsigned int uid; |
| 61 | unsigned int gid; |
| 62 | unsigned long long size; |
Arnd Bergmann | bca3026 | 2018-06-12 15:31:17 +0200 | [diff] [blame] | 63 | struct hostfs_timespec atime, mtime, ctime; |
Al Viro | 39b743c | 2010-06-06 20:08:56 -0400 | [diff] [blame] | 64 | unsigned int blksize; |
| 65 | unsigned long long blocks; |
| 66 | unsigned int maj; |
| 67 | unsigned int min; |
| 68 | }; |
| 69 | |
| 70 | extern int stat_file(const char *path, struct hostfs_stat *p, int fd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | extern int access_file(char *path, int r, int w, int x); |
| 72 | extern int open_file(char *path, int r, int w, int append); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | extern void *open_dir(char *path, int *err_out); |
Richard Weinberger | 0c9bd63 | 2015-03-24 15:47:38 +0100 | [diff] [blame] | 74 | extern void seek_dir(void *stream, unsigned long long pos); |
| 75 | extern char *read_dir(void *stream, unsigned long long *pos_out, |
Geert Uytterhoeven | 3ee6bd8 | 2012-01-27 19:14:58 +0100 | [diff] [blame] | 76 | unsigned long long *ino_out, int *len_out, |
| 77 | unsigned int *type_out); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | extern void close_file(void *stream); |
Al Viro | f8ad850 | 2010-06-06 23:49:18 -0400 | [diff] [blame] | 79 | extern int replace_file(int oldfd, int fd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | extern void close_dir(void *stream); |
| 81 | extern int read_file(int fd, unsigned long long *offset, char *buf, int len); |
| 82 | extern int write_file(int fd, unsigned long long *offset, const char *buf, |
| 83 | int len); |
| 84 | extern int lseek_file(int fd, long long offset, int whence); |
Paolo 'Blaisorblade' Giarrusso | a2d76bd | 2005-07-28 21:16:15 -0700 | [diff] [blame] | 85 | extern int fsync_file(int fd, int datasync); |
Richard Weinberger | b98b910 | 2015-03-04 23:44:54 +0100 | [diff] [blame] | 86 | extern int file_create(char *name, int mode); |
Alberto Bertogli | 5822b7f | 2007-05-08 00:23:16 -0700 | [diff] [blame] | 87 | extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | extern int make_symlink(const char *from, const char *to); |
| 89 | extern int unlink_file(const char *file); |
| 90 | extern int do_mkdir(const char *file, int mode); |
Dominik Brodowski | 6380161 | 2018-03-11 11:34:48 +0100 | [diff] [blame] | 91 | extern int hostfs_do_rmdir(const char *file); |
Jeff Dike | 84b3db0 | 2007-10-16 01:27:13 -0700 | [diff] [blame] | 92 | extern int do_mknod(const char *file, int mode, unsigned int major, |
| 93 | unsigned int minor); |
Colin Ian King | 91e1e54 | 2019-03-17 23:09:09 +0000 | [diff] [blame] | 94 | extern int link_file(const char *to, const char *from); |
WANG Cong | ea7e743 | 2008-11-19 15:36:46 -0800 | [diff] [blame] | 95 | extern int hostfs_do_readlink(char *file, char *buf, int size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | extern int rename_file(char *from, char *to); |
Miklos Szeredi | 9a423bb | 2014-07-23 15:15:35 +0200 | [diff] [blame] | 97 | extern int rename2_file(char *from, char *to, unsigned int flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | extern int do_statfs(char *root, long *bsize_out, long long *blocks_out, |
| 99 | long long *bfree_out, long long *bavail_out, |
| 100 | long long *files_out, long long *ffree_out, |
Richard Weinberger | 1b627d5 | 2010-10-26 14:21:18 -0700 | [diff] [blame] | 101 | void *fsid_out, int fsid_size, long *namelen_out); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | #endif |