e80b6f836140e7fc2c6ecf4f17658444afcbdb93
[linux-2.6.git] / fs / hostfs / hostfs.h
1 /* 
2  * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef __UM_FS_HOSTFS
7 #define __UM_FS_HOSTFS
8
9 #include "linux/fs.h"
10 #include "filehandle.h"
11 #include "os.h"
12
13 /* These are exactly the same definitions as in fs.h, but the names are 
14  * changed so that this file can be included in both kernel and user files.
15  */
16
17 #define EXTERNFS_ATTR_MODE      1
18 #define EXTERNFS_ATTR_UID       2
19 #define EXTERNFS_ATTR_GID       4
20 #define EXTERNFS_ATTR_SIZE      8
21 #define EXTERNFS_ATTR_ATIME     16
22 #define EXTERNFS_ATTR_MTIME     32
23 #define EXTERNFS_ATTR_CTIME     64
24 #define EXTERNFS_ATTR_ATIME_SET 128
25 #define EXTERNFS_ATTR_MTIME_SET 256
26 #define EXTERNFS_ATTR_FORCE     512     /* Not a change, but a change it */
27 #define EXTERNFS_ATTR_ATTR_FLAG 1024
28
29 struct externfs_iattr {
30         unsigned int    ia_valid;
31         mode_t          ia_mode;
32         uid_t           ia_uid;
33         gid_t           ia_gid;
34         loff_t          ia_size;
35         time_t          ia_atime;
36         time_t          ia_mtime;
37         time_t          ia_ctime;
38         unsigned int    ia_attr_flags;
39 };
40
41 struct externfs_data {
42         struct externfs_file_ops *file_ops;
43         struct externfs_mount_ops *mount_ops;
44 };
45
46 struct externfs_inode {
47         struct inode vfs_inode;
48         struct externfs_file_ops *ops;
49 };
50
51 struct externfs_mount_ops {
52         struct externfs_data *(*mount)(char *mount_arg);
53         struct externfs_inode *(*init_file)(struct externfs_data *ed);
54 };
55
56 struct externfs_file_ops {
57         int (*stat_file)(const char *path, struct externfs_data *ed, 
58                          dev_t *dev_out, unsigned long long *inode_out, 
59                          int *mode_out, int *nlink_out, int *uid_out, 
60                          int *gid_out, unsigned long long *size_out, 
61                          unsigned long *atime_out, unsigned long *mtime_out,
62                          unsigned long *ctime_out, int *blksize_out, 
63                          unsigned long long *blocks_out);
64         int (*file_type)(const char *path, int *rdev, 
65                          struct externfs_data *ed);
66         int (*access_file)(char *path, int r, int w, int x, int uid, int gid, 
67                            struct externfs_data *ed);
68         int (*open_file)(struct externfs_inode *ext, char *file, 
69                          int uid, int gid, struct inode *inode, 
70                          struct externfs_data *ed);
71         void (*close_file)(struct externfs_inode *ext, 
72                            unsigned long long size);
73         void *(*open_dir)(char *path, int uid, int gid, 
74                           struct externfs_data *ed);
75         char *(*read_dir)(void *stream, unsigned long long *pos, 
76                           unsigned long long *ino_out, int *len_out, 
77                           struct externfs_data *ed);
78         int (*read_file)(struct externfs_inode *ext, 
79                          unsigned long long offset, char *buf, int len, 
80                          int ignore_start, int ignore_end,
81                          void (*completion)(char *, int, void *), void *arg, 
82                          struct externfs_data *ed);
83         int (*write_file)(struct externfs_inode *ext, 
84                           unsigned long long offset, const char *buf, 
85                           int start, int len, 
86                           void (*completion)(char *, int, void *), void *arg, 
87                           struct externfs_data *ed);
88         int (*map_file_page)(struct externfs_inode *ext, 
89                              unsigned long long offset, char *buf, int w, 
90                              struct externfs_data *ed);
91         void (*close_dir)(void *stream, struct externfs_data *ed);
92         void (*invisible)(struct externfs_inode *ext);
93         int (*create_file)(struct externfs_inode *ext, char *path, 
94                            int mode, int uid, int gid, struct inode *inode, 
95                            struct externfs_data *ed);
96         int (*set_attr)(const char *path, struct externfs_iattr *attrs, 
97                         struct externfs_data *ed);
98         int (*make_symlink)(const char *from, const char *to, int uid, int gid,
99                             struct externfs_data *ed);
100         int (*unlink_file)(const char *path, struct externfs_data *ed);
101         int (*make_dir)(const char *path, int mode, int uid, int gid, 
102                         struct externfs_data *ed);
103         int (*remove_dir)(const char *path, int uid, int gid, 
104                           struct externfs_data *ed);
105         int (*make_node)(const char *path, int mode, int uid, int gid, 
106                          int type, int maj, int min, struct externfs_data *ed);
107         int (*link_file)(const char *to, const char *from, int uid, int gid, 
108                          struct externfs_data *ed);
109         int (*read_link)(char *path, int uid, int gid, char *buf, int size, 
110                          struct externfs_data *ed);
111         int (*rename_file)(char *from, char *to, struct externfs_data *ed);
112         int (*statfs)(long *bsize_out, long long *blocks_out, 
113                       long long *bfree_out, long long *bavail_out, 
114                       long long *files_out, long long *ffree_out,
115                       void *fsid_out, int fsid_size, long *namelen_out, 
116                       long *spare_out, struct externfs_data *ed);
117         int (*truncate_file)(struct externfs_inode *ext, __u64 size, 
118                              struct externfs_data *ed);
119 };
120
121 #define HOSTFS_BUFSIZE 64
122
123 extern int register_externfs(char *name, struct externfs_mount_ops *mount_ops);
124 extern void unregister_externfs(char *name);
125 extern void init_externfs(struct externfs_data *ed, 
126                           struct externfs_file_ops *ops);
127 struct externfs_data *inode_externfs_info(struct inode *inode);
128
129 extern char *generic_root_filename(char *mount_arg);
130 extern void host_close_file(void *stream);
131 extern int host_read_file(int fd, unsigned long long offset, char *buf, 
132                           int len);
133 extern int host_open_file(const char *path[], int r, int w,
134                           struct file_handle *fh);
135 extern void *host_open_dir(const char *path[]);
136 extern char *host_read_dir(void *stream, unsigned long long *pos, 
137                            unsigned long long *ino_out, int *len_out);
138 extern int host_file_type(const char *path[], int *rdev);
139 extern char *host_root_filename(char *mount_arg);
140 extern char *get_path(const char *path[], char *buf, int size);
141 extern void free_path(const char *buf, char *tmp);
142 extern int host_create_file(const char *path[], int mode, 
143                             struct file_handle *fh);
144 extern int host_set_attr(const char *path[], struct externfs_iattr *attrs);
145 extern int host_make_symlink(const char *from[], const char *to);
146 extern int host_unlink_file(const char *path[]);
147 extern int host_make_dir(const char *path[], int mode);
148 extern int host_remove_dir(const char *path[]);
149 extern int host_link_file(const char *to[], const char *from[]);
150 extern int host_read_link(const char *path[], char *buf, int size);
151 extern int host_rename_file(const char *from[], const char *to[]);
152 extern int host_stat_fs(const char *path[], long *bsize_out, 
153                         long long *blocks_out, long long *bfree_out, 
154                         long long *bavail_out, long long *files_out, 
155                         long long *ffree_out, void *fsid_out, int fsid_size, 
156                         long *namelen_out, long *spare_out);
157 extern int host_stat_file(const char *path[], int *dev_out, 
158                           unsigned long long *inode_out, int *mode_out, 
159                           int *nlink_out, int *uid_out, int *gid_out, 
160                           unsigned long long *size_out, 
161                           unsigned long *atime_out, unsigned long *mtime_out,
162                           unsigned long *ctime_out, int *blksize_out,
163                           unsigned long long *blocks_out);
164
165 extern char *generic_host_read_dir(void *stream, unsigned long long *pos, 
166                               unsigned long long *ino_out, int *len_out, 
167                               void *mount);
168 extern int generic_host_read_file(int fd, unsigned long long offset, char *buf,
169                              int len, void *mount);
170 extern void generic_host_close_file(void *stream, unsigned long long size,
171                                     void *mount);
172 extern int generic_host_truncate_file(struct file_handle *fh, __u64 size, 
173                                       void *m);
174
175 extern char *inode_name_prefix(struct inode *inode, char *prefix);
176
177 #endif
178
179 /*
180  * Overrides for Emacs so that we follow Linus's tabbing style.
181  * Emacs will notice this stuff at the end of the file and automatically
182  * adjust the settings for this buffer only.  This must remain at the end
183  * of the file.
184  * ---------------------------------------------------------------------------
185  * Local variables:
186  * c-file-style: "linux"
187  * End:
188  */