blob: 33b8423ef0c994a307a3bb9bf8ec63121cfd64fb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __UM_FS_HOSTFS
3#define __UM_FS_HOSTFS
4
Al Viro37185b32012-10-08 03:27:32 +01005#include <os.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Jeff Dike84b3db02007-10-16 01:27:13 -07007/*
8 * These are exactly the same definitions as in fs.h, but the names are
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * changed so that this file can be included in both kernel and user files.
10 */
11
12#define HOSTFS_ATTR_MODE 1
13#define HOSTFS_ATTR_UID 2
14#define HOSTFS_ATTR_GID 4
15#define HOSTFS_ATTR_SIZE 8
16#define HOSTFS_ATTR_ATIME 16
17#define HOSTFS_ATTR_MTIME 32
18#define HOSTFS_ATTR_CTIME 64
19#define HOSTFS_ATTR_ATIME_SET 128
20#define HOSTFS_ATTR_MTIME_SET 256
21
NeilBrown4cdfffc2018-08-17 15:44:37 -070022/* This one is unused by hostfs. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
24#define HOSTFS_ATTR_ATTR_FLAG 1024
25
Jeff Dike84b3db02007-10-16 01:27:13 -070026/*
27 * If you are very careful, you'll notice that these two are missing:
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 *
29 * #define ATTR_KILL_SUID 2048
30 * #define ATTR_KILL_SGID 4096
31 *
Justin P. Mattock631dd1a2010-10-18 11:03:14 +020032 * and this is because they were added in 2.5 development.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * Actually, they are not needed by most ->setattr() methods - they are set by
34 * callers of notify_change() to notify that the setuid/setgid bits must be
35 * dropped.
36 * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
37 * is on, and remove the appropriate bits from attr->ia_mode (attr is a
38 * "struct iattr *"). -BlaisorBlade
39 */
40
41struct hostfs_iattr {
42 unsigned int ia_valid;
Al Viro138d5702011-07-26 04:48:59 -040043 unsigned short ia_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 uid_t ia_uid;
45 gid_t ia_gid;
46 loff_t ia_size;
47 struct timespec ia_atime;
48 struct timespec ia_mtime;
49 struct timespec ia_ctime;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050};
51
Al Viro39b743c2010-06-06 20:08:56 -040052struct hostfs_stat {
53 unsigned long long ino;
54 unsigned int mode;
55 unsigned int nlink;
56 unsigned int uid;
57 unsigned int gid;
58 unsigned long long size;
59 struct timespec atime, mtime, ctime;
60 unsigned int blksize;
61 unsigned long long blocks;
62 unsigned int maj;
63 unsigned int min;
64};
65
66extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067extern int access_file(char *path, int r, int w, int x);
68extern int open_file(char *path, int r, int w, int append);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern void *open_dir(char *path, int *err_out);
Richard Weinberger0c9bd632015-03-24 15:47:38 +010070extern void seek_dir(void *stream, unsigned long long pos);
71extern char *read_dir(void *stream, unsigned long long *pos_out,
Geert Uytterhoeven3ee6bd82012-01-27 19:14:58 +010072 unsigned long long *ino_out, int *len_out,
73 unsigned int *type_out);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern void close_file(void *stream);
Al Virof8ad8502010-06-06 23:49:18 -040075extern int replace_file(int oldfd, int fd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076extern void close_dir(void *stream);
77extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
78extern int write_file(int fd, unsigned long long *offset, const char *buf,
79 int len);
80extern int lseek_file(int fd, long long offset, int whence);
Paolo 'Blaisorblade' Giarrussoa2d76bd2005-07-28 21:16:15 -070081extern int fsync_file(int fd, int datasync);
Richard Weinbergerb98b9102015-03-04 23:44:54 +010082extern int file_create(char *name, int mode);
Alberto Bertogli5822b7f2007-05-08 00:23:16 -070083extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084extern int make_symlink(const char *from, const char *to);
85extern int unlink_file(const char *file);
86extern int do_mkdir(const char *file, int mode);
Dominik Brodowski63801612018-03-11 11:34:48 +010087extern int hostfs_do_rmdir(const char *file);
Jeff Dike84b3db02007-10-16 01:27:13 -070088extern int do_mknod(const char *file, int mode, unsigned int major,
89 unsigned int minor);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090extern int link_file(const char *from, const char *to);
WANG Congea7e7432008-11-19 15:36:46 -080091extern int hostfs_do_readlink(char *file, char *buf, int size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092extern int rename_file(char *from, char *to);
Miklos Szeredi9a423bb2014-07-23 15:15:35 +020093extern int rename2_file(char *from, char *to, unsigned int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
95 long long *bfree_out, long long *bavail_out,
96 long long *files_out, long long *ffree_out,
Richard Weinberger1b627d52010-10-26 14:21:18 -070097 void *fsid_out, int fsid_size, long *namelen_out);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99#endif