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