xref: /OK3568_Linux_fs/kernel/fs/hostfs/hostfs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __UM_FS_HOSTFS
3*4882a593Smuzhiyun #define __UM_FS_HOSTFS
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <os.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun /*
8*4882a593Smuzhiyun  * These are exactly the same definitions as in fs.h, but the names are
9*4882a593Smuzhiyun  * changed so that this file can be included in both kernel and user files.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #define HOSTFS_ATTR_MODE	1
13*4882a593Smuzhiyun #define HOSTFS_ATTR_UID 	2
14*4882a593Smuzhiyun #define HOSTFS_ATTR_GID 	4
15*4882a593Smuzhiyun #define HOSTFS_ATTR_SIZE	8
16*4882a593Smuzhiyun #define HOSTFS_ATTR_ATIME	16
17*4882a593Smuzhiyun #define HOSTFS_ATTR_MTIME	32
18*4882a593Smuzhiyun #define HOSTFS_ATTR_CTIME	64
19*4882a593Smuzhiyun #define HOSTFS_ATTR_ATIME_SET	128
20*4882a593Smuzhiyun #define HOSTFS_ATTR_MTIME_SET	256
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun /* This one is unused by hostfs. */
23*4882a593Smuzhiyun #define HOSTFS_ATTR_FORCE	512	/* Not a change, but a change it */
24*4882a593Smuzhiyun #define HOSTFS_ATTR_ATTR_FLAG	1024
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun /*
27*4882a593Smuzhiyun  * If you are very careful, you'll notice that these two are missing:
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  * #define ATTR_KILL_SUID	2048
30*4882a593Smuzhiyun  * #define ATTR_KILL_SGID	4096
31*4882a593Smuzhiyun  *
32*4882a593Smuzhiyun  * and this is because they were added in 2.5 development.
33*4882a593Smuzhiyun  * Actually, they are not needed by most ->setattr() methods - they are set by
34*4882a593Smuzhiyun  * callers of notify_change() to notify that the setuid/setgid bits must be
35*4882a593Smuzhiyun  * dropped.
36*4882a593Smuzhiyun  * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
37*4882a593Smuzhiyun  * is on, and remove the appropriate bits from attr->ia_mode (attr is a
38*4882a593Smuzhiyun  * "struct iattr *"). -BlaisorBlade
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun struct hostfs_timespec {
41*4882a593Smuzhiyun 	long long tv_sec;
42*4882a593Smuzhiyun 	long long tv_nsec;
43*4882a593Smuzhiyun };
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun struct hostfs_iattr {
46*4882a593Smuzhiyun 	unsigned int		ia_valid;
47*4882a593Smuzhiyun 	unsigned short		ia_mode;
48*4882a593Smuzhiyun 	uid_t			ia_uid;
49*4882a593Smuzhiyun 	gid_t			ia_gid;
50*4882a593Smuzhiyun 	loff_t			ia_size;
51*4882a593Smuzhiyun 	struct hostfs_timespec	ia_atime;
52*4882a593Smuzhiyun 	struct hostfs_timespec	ia_mtime;
53*4882a593Smuzhiyun 	struct hostfs_timespec	ia_ctime;
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun struct hostfs_stat {
57*4882a593Smuzhiyun 	unsigned long long ino;
58*4882a593Smuzhiyun 	unsigned int mode;
59*4882a593Smuzhiyun 	unsigned int nlink;
60*4882a593Smuzhiyun 	unsigned int uid;
61*4882a593Smuzhiyun 	unsigned int gid;
62*4882a593Smuzhiyun 	unsigned long long size;
63*4882a593Smuzhiyun 	struct hostfs_timespec atime, mtime, ctime;
64*4882a593Smuzhiyun 	unsigned int blksize;
65*4882a593Smuzhiyun 	unsigned long long blocks;
66*4882a593Smuzhiyun 	unsigned int maj;
67*4882a593Smuzhiyun 	unsigned int min;
68*4882a593Smuzhiyun };
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
71*4882a593Smuzhiyun extern int access_file(char *path, int r, int w, int x);
72*4882a593Smuzhiyun extern int open_file(char *path, int r, int w, int append);
73*4882a593Smuzhiyun extern void *open_dir(char *path, int *err_out);
74*4882a593Smuzhiyun extern void seek_dir(void *stream, unsigned long long pos);
75*4882a593Smuzhiyun extern char *read_dir(void *stream, unsigned long long *pos_out,
76*4882a593Smuzhiyun 		      unsigned long long *ino_out, int *len_out,
77*4882a593Smuzhiyun 		      unsigned int *type_out);
78*4882a593Smuzhiyun extern void close_file(void *stream);
79*4882a593Smuzhiyun extern int replace_file(int oldfd, int fd);
80*4882a593Smuzhiyun extern void close_dir(void *stream);
81*4882a593Smuzhiyun extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
82*4882a593Smuzhiyun extern int write_file(int fd, unsigned long long *offset, const char *buf,
83*4882a593Smuzhiyun 		      int len);
84*4882a593Smuzhiyun extern int lseek_file(int fd, long long offset, int whence);
85*4882a593Smuzhiyun extern int fsync_file(int fd, int datasync);
86*4882a593Smuzhiyun extern int file_create(char *name, int mode);
87*4882a593Smuzhiyun extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
88*4882a593Smuzhiyun extern int make_symlink(const char *from, const char *to);
89*4882a593Smuzhiyun extern int unlink_file(const char *file);
90*4882a593Smuzhiyun extern int do_mkdir(const char *file, int mode);
91*4882a593Smuzhiyun extern int hostfs_do_rmdir(const char *file);
92*4882a593Smuzhiyun extern int do_mknod(const char *file, int mode, unsigned int major,
93*4882a593Smuzhiyun 		    unsigned int minor);
94*4882a593Smuzhiyun extern int link_file(const char *to, const char *from);
95*4882a593Smuzhiyun extern int hostfs_do_readlink(char *file, char *buf, int size);
96*4882a593Smuzhiyun extern int rename_file(char *from, char *to);
97*4882a593Smuzhiyun extern int rename2_file(char *from, char *to, unsigned int flags);
98*4882a593Smuzhiyun extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
99*4882a593Smuzhiyun 		     long long *bfree_out, long long *bavail_out,
100*4882a593Smuzhiyun 		     long long *files_out, long long *ffree_out,
101*4882a593Smuzhiyun 		     void *fsid_out, int fsid_size, long *namelen_out);
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun #endif
104