xref: /openbmc/linux/fs/hostfs/hostfs.h (revision 74ce793b)
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;
6639b743c6SAl Viro 	unsigned int maj;
6739b743c6SAl Viro 	unsigned int min;
68*74ce793bSMickaël Salaün 	dev_t dev;
6939b743c6SAl Viro };
7039b743c6SAl Viro 
7139b743c6SAl Viro extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
721da177e4SLinus Torvalds extern int access_file(char *path, int r, int w, int x);
731da177e4SLinus Torvalds extern int open_file(char *path, int r, int w, int append);
741da177e4SLinus Torvalds extern void *open_dir(char *path, int *err_out);
750c9bd636SRichard Weinberger extern void seek_dir(void *stream, unsigned long long pos);
760c9bd636SRichard Weinberger extern char *read_dir(void *stream, unsigned long long *pos_out,
773ee6bd8eSGeert Uytterhoeven 		      unsigned long long *ino_out, int *len_out,
783ee6bd8eSGeert Uytterhoeven 		      unsigned int *type_out);
791da177e4SLinus Torvalds extern void close_file(void *stream);
80f8ad850fSAl Viro extern int replace_file(int oldfd, int fd);
811da177e4SLinus Torvalds extern void close_dir(void *stream);
821da177e4SLinus Torvalds extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
831da177e4SLinus Torvalds extern int write_file(int fd, unsigned long long *offset, const char *buf,
841da177e4SLinus Torvalds 		      int len);
851da177e4SLinus Torvalds extern int lseek_file(int fd, long long offset, int whence);
86a2d76bd8SPaolo 'Blaisorblade' Giarrusso extern int fsync_file(int fd, int datasync);
87b98b9102SRichard Weinberger extern int file_create(char *name, int mode);
885822b7faSAlberto Bertogli extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
891da177e4SLinus Torvalds extern int make_symlink(const char *from, const char *to);
901da177e4SLinus Torvalds extern int unlink_file(const char *file);
911da177e4SLinus Torvalds extern int do_mkdir(const char *file, int mode);
926380161cSDominik Brodowski extern int hostfs_do_rmdir(const char *file);
9384b3db04SJeff Dike extern int do_mknod(const char *file, int mode, unsigned int major,
9484b3db04SJeff Dike 		    unsigned int minor);
9591e1e547SColin Ian King extern int link_file(const char *to, const char *from);
96ea7e743eSWANG Cong extern int hostfs_do_readlink(char *file, char *buf, int size);
971da177e4SLinus Torvalds extern int rename_file(char *from, char *to);
989a423bb6SMiklos Szeredi extern int rename2_file(char *from, char *to, unsigned int flags);
991da177e4SLinus Torvalds extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
1001da177e4SLinus Torvalds 		     long long *bfree_out, long long *bavail_out,
1011da177e4SLinus Torvalds 		     long long *files_out, long long *ffree_out,
1021b627d57SRichard Weinberger 		     void *fsid_out, int fsid_size, long *namelen_out);
1031da177e4SLinus Torvalds 
1041da177e4SLinus Torvalds #endif
105