Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __UM_FS_HOSTFS
0003 #define __UM_FS_HOSTFS
0004 
0005 #include <os.h>
0006 
0007 /*
0008  * These are exactly the same definitions as in fs.h, but the names are
0009  * changed so that this file can be included in both kernel and user files.
0010  */
0011 
0012 #define HOSTFS_ATTR_MODE    1
0013 #define HOSTFS_ATTR_UID     2
0014 #define HOSTFS_ATTR_GID     4
0015 #define HOSTFS_ATTR_SIZE    8
0016 #define HOSTFS_ATTR_ATIME   16
0017 #define HOSTFS_ATTR_MTIME   32
0018 #define HOSTFS_ATTR_CTIME   64
0019 #define HOSTFS_ATTR_ATIME_SET   128
0020 #define HOSTFS_ATTR_MTIME_SET   256
0021 
0022 /* This one is unused by hostfs. */
0023 #define HOSTFS_ATTR_FORCE   512 /* Not a change, but a change it */
0024 #define HOSTFS_ATTR_ATTR_FLAG   1024
0025 
0026 /*
0027  * If you are very careful, you'll notice that these two are missing:
0028  *
0029  * #define ATTR_KILL_SUID   2048
0030  * #define ATTR_KILL_SGID   4096
0031  *
0032  * and this is because they were added in 2.5 development.
0033  * Actually, they are not needed by most ->setattr() methods - they are set by
0034  * callers of notify_change() to notify that the setuid/setgid bits must be
0035  * dropped.
0036  * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
0037  * is on, and remove the appropriate bits from attr->ia_mode (attr is a
0038  * "struct iattr *"). -BlaisorBlade
0039  */
0040 struct hostfs_timespec {
0041     long long tv_sec;
0042     long long tv_nsec;
0043 };
0044 
0045 struct hostfs_iattr {
0046     unsigned int        ia_valid;
0047     unsigned short      ia_mode;
0048     uid_t           ia_uid;
0049     gid_t           ia_gid;
0050     loff_t          ia_size;
0051     struct hostfs_timespec  ia_atime;
0052     struct hostfs_timespec  ia_mtime;
0053     struct hostfs_timespec  ia_ctime;
0054 };
0055 
0056 struct hostfs_stat {
0057     unsigned long long ino;
0058     unsigned int mode;
0059     unsigned int nlink;
0060     unsigned int uid;
0061     unsigned int gid;
0062     unsigned long long size;
0063     struct hostfs_timespec atime, mtime, ctime;
0064     unsigned int blksize;
0065     unsigned long long blocks;
0066     unsigned int maj;
0067     unsigned int min;
0068 };
0069 
0070 extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
0071 extern int access_file(char *path, int r, int w, int x);
0072 extern int open_file(char *path, int r, int w, int append);
0073 extern void *open_dir(char *path, int *err_out);
0074 extern void seek_dir(void *stream, unsigned long long pos);
0075 extern char *read_dir(void *stream, unsigned long long *pos_out,
0076               unsigned long long *ino_out, int *len_out,
0077               unsigned int *type_out);
0078 extern void close_file(void *stream);
0079 extern int replace_file(int oldfd, int fd);
0080 extern void close_dir(void *stream);
0081 extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
0082 extern int write_file(int fd, unsigned long long *offset, const char *buf,
0083               int len);
0084 extern int lseek_file(int fd, long long offset, int whence);
0085 extern int fsync_file(int fd, int datasync);
0086 extern int file_create(char *name, int mode);
0087 extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
0088 extern int make_symlink(const char *from, const char *to);
0089 extern int unlink_file(const char *file);
0090 extern int do_mkdir(const char *file, int mode);
0091 extern int hostfs_do_rmdir(const char *file);
0092 extern int do_mknod(const char *file, int mode, unsigned int major,
0093             unsigned int minor);
0094 extern int link_file(const char *to, const char *from);
0095 extern int hostfs_do_readlink(char *file, char *buf, int size);
0096 extern int rename_file(char *from, char *to);
0097 extern int rename2_file(char *from, char *to, unsigned int flags);
0098 extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
0099              long long *bfree_out, long long *bavail_out,
0100              long long *files_out, long long *ffree_out,
0101              void *fsid_out, int fsid_size, long *namelen_out);
0102 
0103 #endif