blob: 6bbd75c5589bc90c2a882c7e48a2fba9a35502ef [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __UM_FS_HOSTFS
2#define __UM_FS_HOSTFS
3
4#include "os.h"
5
Jeff Dike84b3db02007-10-16 01:27:13 -07006/*
7 * These are exactly the same definitions as in fs.h, but the names are
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * changed so that this file can be included in both kernel and user files.
9 */
10
11#define HOSTFS_ATTR_MODE 1
12#define HOSTFS_ATTR_UID 2
13#define HOSTFS_ATTR_GID 4
14#define HOSTFS_ATTR_SIZE 8
15#define HOSTFS_ATTR_ATIME 16
16#define HOSTFS_ATTR_MTIME 32
17#define HOSTFS_ATTR_CTIME 64
18#define HOSTFS_ATTR_ATIME_SET 128
19#define HOSTFS_ATTR_MTIME_SET 256
20
21/* These two are unused by hostfs. */
22#define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
23#define HOSTFS_ATTR_ATTR_FLAG 1024
24
Jeff Dike84b3db02007-10-16 01:27:13 -070025/*
26 * If you are very careful, you'll notice that these two are missing:
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 *
28 * #define ATTR_KILL_SUID 2048
29 * #define ATTR_KILL_SGID 4096
30 *
31 * and this is because they were added in 2.5 development in this patch:
32 *
33 * http://linux.bkbits.net:8080/linux-2.5/
34 * cset@3caf4a12k4XgDzK7wyK-TGpSZ9u2Ww?nav=index.html
35 * |src/.|src/include|src/include/linux|related/include/linux/fs.h
36 *
37 * Actually, they are not needed by most ->setattr() methods - they are set by
38 * callers of notify_change() to notify that the setuid/setgid bits must be
39 * dropped.
40 * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
41 * is on, and remove the appropriate bits from attr->ia_mode (attr is a
42 * "struct iattr *"). -BlaisorBlade
43 */
44
45struct hostfs_iattr {
46 unsigned int ia_valid;
47 mode_t ia_mode;
48 uid_t ia_uid;
49 gid_t ia_gid;
50 loff_t ia_size;
51 struct timespec ia_atime;
52 struct timespec ia_mtime;
53 struct timespec ia_ctime;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054};
55
Al Viro39b743c2010-06-06 20:08:56 -040056struct hostfs_stat {
57 unsigned long long ino;
58 unsigned int mode;
59 unsigned int nlink;
60 unsigned int uid;
61 unsigned int gid;
62 unsigned long long size;
63 struct timespec atime, mtime, ctime;
64 unsigned int blksize;
65 unsigned long long blocks;
66 unsigned int maj;
67 unsigned int min;
68};
69
70extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071extern int access_file(char *path, int r, int w, int x);
72extern int open_file(char *path, int r, int w, int append);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern void *open_dir(char *path, int *err_out);
74extern char *read_dir(void *stream, unsigned long long *pos,
75 unsigned long long *ino_out, int *len_out);
76extern void close_file(void *stream);
Al Virof8ad8502010-06-06 23:49:18 -040077extern int replace_file(int oldfd, int fd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern void close_dir(void *stream);
79extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
80extern int write_file(int fd, unsigned long long *offset, const char *buf,
81 int len);
82extern int lseek_file(int fd, long long offset, int whence);
Paolo 'Blaisorblade' Giarrussoa2d76bd2005-07-28 21:16:15 -070083extern int fsync_file(int fd, int datasync);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084extern int file_create(char *name, int ur, int uw, int ux, int gr,
85 int gw, int gx, int or, int ow, int ox);
Alberto Bertogli5822b7f2007-05-08 00:23:16 -070086extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087extern int make_symlink(const char *from, const char *to);
88extern int unlink_file(const char *file);
89extern int do_mkdir(const char *file, int mode);
90extern int do_rmdir(const char *file);
Jeff Dike84b3db02007-10-16 01:27:13 -070091extern int do_mknod(const char *file, int mode, unsigned int major,
92 unsigned int minor);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern int link_file(const char *from, const char *to);
WANG Congea7e7432008-11-19 15:36:46 -080094extern int hostfs_do_readlink(char *file, char *buf, int size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern int rename_file(char *from, char *to);
96extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
97 long long *bfree_out, long long *bavail_out,
98 long long *files_out, long long *ffree_out,
99 void *fsid_out, int fsid_size, long *namelen_out,
100 long *spare_out);
101
102#endif