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