xref: /linux/fs/hostfs/hostfs.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef __UM_FS_HOSTFS
31da177e4SLinus Torvalds #define __UM_FS_HOSTFS
41da177e4SLinus Torvalds 
537185b33SAl Viro #include <os.h>
61da177e4SLinus Torvalds 
784b3db04SJeff Dike /*
884b3db04SJeff Dike  * These are exactly the same definitions as in fs.h, but the names are
91da177e4SLinus Torvalds  * changed so that this file can be included in both kernel and user files.
101da177e4SLinus Torvalds  */
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #define HOSTFS_ATTR_MODE	1
131da177e4SLinus Torvalds #define HOSTFS_ATTR_UID 	2
141da177e4SLinus Torvalds #define HOSTFS_ATTR_GID 	4
151da177e4SLinus Torvalds #define HOSTFS_ATTR_SIZE	8
161da177e4SLinus Torvalds #define HOSTFS_ATTR_ATIME	16
171da177e4SLinus Torvalds #define HOSTFS_ATTR_MTIME	32
181da177e4SLinus Torvalds #define HOSTFS_ATTR_CTIME	64
191da177e4SLinus Torvalds #define HOSTFS_ATTR_ATIME_SET	128
201da177e4SLinus Torvalds #define HOSTFS_ATTR_MTIME_SET	256
211da177e4SLinus Torvalds 
224cdfffc8SNeilBrown /* This one is unused by hostfs. */
231da177e4SLinus Torvalds #define HOSTFS_ATTR_FORCE	512	/* Not a change, but a change it */
241da177e4SLinus Torvalds #define HOSTFS_ATTR_ATTR_FLAG	1024
251da177e4SLinus Torvalds 
2684b3db04SJeff Dike /*
2784b3db04SJeff Dike  * If you are very careful, you'll notice that these two are missing:
281da177e4SLinus Torvalds  *
291da177e4SLinus Torvalds  * #define ATTR_KILL_SUID	2048
301da177e4SLinus Torvalds  * #define ATTR_KILL_SGID	4096
311da177e4SLinus Torvalds  *
32631dd1a8SJustin P. Mattock  * and this is because they were added in 2.5 development.
331da177e4SLinus Torvalds  * Actually, they are not needed by most ->setattr() methods - they are set by
341da177e4SLinus Torvalds  * callers of notify_change() to notify that the setuid/setgid bits must be
351da177e4SLinus Torvalds  * dropped.
361da177e4SLinus Torvalds  * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
371da177e4SLinus Torvalds  * is on, and remove the appropriate bits from attr->ia_mode (attr is a
381da177e4SLinus Torvalds  * "struct iattr *"). -BlaisorBlade
391da177e4SLinus Torvalds  */
40bca30265SArnd Bergmann struct hostfs_timespec {
41bca30265SArnd Bergmann 	long long tv_sec;
42bca30265SArnd Bergmann 	long long tv_nsec;
43bca30265SArnd Bergmann };
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds struct hostfs_iattr {
461da177e4SLinus Torvalds 	unsigned int		ia_valid;
47138d570dSAl Viro 	unsigned short		ia_mode;
481da177e4SLinus Torvalds 	uid_t			ia_uid;
491da177e4SLinus Torvalds 	gid_t			ia_gid;
501da177e4SLinus Torvalds 	loff_t			ia_size;
51bca30265SArnd Bergmann 	struct hostfs_timespec	ia_atime;
52bca30265SArnd Bergmann 	struct hostfs_timespec	ia_mtime;
53bca30265SArnd Bergmann 	struct hostfs_timespec	ia_ctime;
541da177e4SLinus Torvalds };
551da177e4SLinus Torvalds 
5639b743c6SAl Viro struct hostfs_stat {
5739b743c6SAl Viro 	unsigned long long ino;
5839b743c6SAl Viro 	unsigned int mode;
5939b743c6SAl Viro 	unsigned int nlink;
6039b743c6SAl Viro 	unsigned int uid;
6139b743c6SAl Viro 	unsigned int gid;
6239b743c6SAl Viro 	unsigned long long size;
63bca30265SArnd Bergmann 	struct hostfs_timespec atime, mtime, ctime;
6439b743c6SAl Viro 	unsigned int blksize;
6539b743c6SAl Viro 	unsigned long long blocks;
66*267ed02cSJohannes Berg 	struct {
6739b743c6SAl Viro 		unsigned int maj;
6839b743c6SAl Viro 		unsigned int min;
69*267ed02cSJohannes Berg 	} rdev, dev;
7039b743c6SAl Viro };
7139b743c6SAl Viro 
7239b743c6SAl Viro extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
731da177e4SLinus Torvalds extern int access_file(char *path, int r, int w, int x);
741da177e4SLinus Torvalds extern int open_file(char *path, int r, int w, int append);
751da177e4SLinus Torvalds extern void *open_dir(char *path, int *err_out);
760c9bd636SRichard Weinberger extern void seek_dir(void *stream, unsigned long long pos);
770c9bd636SRichard Weinberger extern char *read_dir(void *stream, unsigned long long *pos_out,
783ee6bd8eSGeert Uytterhoeven 		      unsigned long long *ino_out, int *len_out,
793ee6bd8eSGeert Uytterhoeven 		      unsigned int *type_out);
801da177e4SLinus Torvalds extern void close_file(void *stream);
81f8ad850fSAl Viro extern int replace_file(int oldfd, int fd);
821da177e4SLinus Torvalds extern void close_dir(void *stream);
831da177e4SLinus Torvalds extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
841da177e4SLinus Torvalds extern int write_file(int fd, unsigned long long *offset, const char *buf,
851da177e4SLinus Torvalds 		      int len);
861da177e4SLinus Torvalds extern int lseek_file(int fd, long long offset, int whence);
87a2d76bd8SPaolo 'Blaisorblade' Giarrusso extern int fsync_file(int fd, int datasync);
88b98b9102SRichard Weinberger extern int file_create(char *name, int mode);
895822b7faSAlberto Bertogli extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
901da177e4SLinus Torvalds extern int make_symlink(const char *from, const char *to);
911da177e4SLinus Torvalds extern int unlink_file(const char *file);
921da177e4SLinus Torvalds extern int do_mkdir(const char *file, int mode);
936380161cSDominik Brodowski extern int hostfs_do_rmdir(const char *file);
9484b3db04SJeff Dike extern int do_mknod(const char *file, int mode, unsigned int major,
9584b3db04SJeff Dike 		    unsigned int minor);
9691e1e547SColin Ian King extern int link_file(const char *to, const char *from);
97ea7e743eSWANG Cong extern int hostfs_do_readlink(char *file, char *buf, int size);
981da177e4SLinus Torvalds extern int rename_file(char *from, char *to);
999a423bb6SMiklos Szeredi extern int rename2_file(char *from, char *to, unsigned int flags);
1001da177e4SLinus Torvalds extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
1011da177e4SLinus Torvalds 		     long long *bfree_out, long long *bavail_out,
1021da177e4SLinus Torvalds 		     long long *files_out, long long *ffree_out,
1031b627d57SRichard Weinberger 		     void *fsid_out, int fsid_size, long *namelen_out);
1041da177e4SLinus Torvalds 
1051da177e4SLinus Torvalds #endif
106