2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
10 #include "filehandle.h"
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.
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
29 struct externfs_iattr {
30 unsigned int ia_valid;
38 unsigned int ia_attr_flags;
41 struct externfs_data {
42 struct externfs_file_ops *file_ops;
43 struct externfs_mount_ops *mount_ops;
46 struct externfs_inode {
47 struct inode vfs_inode;
48 struct externfs_file_ops *ops;
51 struct externfs_mount_ops {
52 struct externfs_data *(*mount)(char *mount_arg);
53 struct externfs_inode *(*init_file)(struct externfs_data *ed);
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,
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);
121 #define HOSTFS_BUFSIZE 64
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);
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,
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);
165 extern char *generic_host_read_dir(void *stream, unsigned long long *pos,
166 unsigned long long *ino_out, int *len_out,
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,
172 extern int generic_host_truncate_file(struct file_handle *fh, __u64 size,
175 extern char *inode_name_prefix(struct inode *inode, char *prefix);
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
184 * ---------------------------------------------------------------------------
186 * c-file-style: "linux"