xref: /linux/fs/hostfs/hostfs.h (revision 399ead3a6d76cbdd29a716660db5c84a314dab70)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __UM_FS_HOSTFS
3 #define __UM_FS_HOSTFS
4 
5 #include <os.h>
6 #include <generated/asm-offsets.h>
7 
8 struct hostfs_timespec {
9 	long long tv_sec;
10 	long long tv_nsec;
11 };
12 
13 struct hostfs_iattr {
14 	unsigned int		ia_valid;
15 	unsigned short		ia_mode;
16 	uid_t			ia_uid;
17 	gid_t			ia_gid;
18 	loff_t			ia_size;
19 	struct hostfs_timespec	ia_atime;
20 	struct hostfs_timespec	ia_mtime;
21 	struct hostfs_timespec	ia_ctime;
22 };
23 
24 struct hostfs_stat {
25 	unsigned long long ino;
26 	unsigned int mode;
27 	unsigned int nlink;
28 	unsigned int uid;
29 	unsigned int gid;
30 	unsigned long long size;
31 	struct hostfs_timespec atime, mtime, ctime, btime;
32 	unsigned int blksize;
33 	unsigned long long blocks;
34 	struct {
35 		unsigned int maj;
36 		unsigned int min;
37 	} rdev, dev;
38 };
39 
40 extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
41 extern int access_file(char *path, int r, int w, int x);
42 extern int open_file(char *path, int r, int w, int append);
43 extern void *open_dir(char *path, int *err_out);
44 extern void seek_dir(void *stream, unsigned long long pos);
45 extern char *read_dir(void *stream, unsigned long long *pos_out,
46 		      unsigned long long *ino_out, int *len_out,
47 		      unsigned int *type_out);
48 extern void close_file(void *stream);
49 extern int replace_file(int oldfd, int fd);
50 extern void close_dir(void *stream);
51 extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
52 extern int write_file(int fd, unsigned long long *offset, const char *buf,
53 		      int len);
54 extern int lseek_file(int fd, long long offset, int whence);
55 extern int fsync_file(int fd, int datasync);
56 extern int file_create(char *name, int mode);
57 extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
58 extern int make_symlink(const char *from, const char *to);
59 extern int unlink_file(const char *file);
60 extern int do_mkdir(const char *file, int mode);
61 extern int hostfs_do_rmdir(const char *file);
62 extern int do_mknod(const char *file, int mode, unsigned int major,
63 		    unsigned int minor);
64 extern int link_file(const char *to, const char *from);
65 extern int hostfs_do_readlink(char *file, char *buf, int size);
66 extern int rename_file(char *from, char *to);
67 extern int rename2_file(char *from, char *to, unsigned int flags);
68 extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
69 		     long long *bfree_out, long long *bavail_out,
70 		     long long *files_out, long long *ffree_out,
71 		     void *fsid_out, int fsid_size, long *namelen_out);
72 
73 #endif
74