--- ./fs/hostfs/hostfs_kern.c.fix 2004-03-01 18:59:47.000000000 +0100 +++ ./fs/hostfs/hostfs_kern.c 2004-03-01 19:26:03.000000000 +0100 @@ -33,6 +33,30 @@ struct inode vfs_inode; }; +struct hostfs_private_fs_info { /* To fill s_fs_info; it will need a list_head field.*/ + struct hostfs_user_operations *ops; + struct list_head link; +}; + +/* For now no locking, it is called in initialization.*/ +static struct hostfs_private_fs_info hostfs_info; + +int register_hostfs_ops(struct hostfs_user_operations* ops) +{ + hostfs_info.ops = ops; + return 0; +} + +static inline struct hostfs_user_operations* HOSTFS_OPS_INO(struct inode* ino) +{ + return ((struct hostfs_private_fs_info*) ino->i_sb->s_fs_info)->ops; +} + +static inline struct hostfs_user_operations* HOSTFS_OPS_FILE(struct file* file) +{ + return ((struct hostfs_private_fs_info*) file->f_dentry->d_sb->s_fs_info)->ops; +} + static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode) { return(list_entry(inode, struct hostfs_inode_info, vfs_inode)); @@ -927,6 +951,8 @@ sb->s_blocksize_bits = 10; sb->s_magic = HOSTFS_SUPER_MAGIC; sb->s_op = &hostfs_sbops; + /* Just temporary;*/ + sb->s_fs_info = &hostfs_info; if((data == NULL) || (*data == '\0')) data = root_ino; --- ./fs/hostfs/hostfs.h.fix 2004-02-20 18:43:27.000000000 +0100 +++ ./fs/hostfs/hostfs.h 2004-03-01 19:21:05.000000000 +0100 @@ -31,6 +31,7 @@ unsigned int ia_attr_flags; }; +#if 0 extern int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, int *nlink_out, int *uid_out, int *gid_out, unsigned long long *size_out, struct timespec *atime_out, @@ -64,6 +65,46 @@ long long *files_out, long long *ffree_out, void *fsid_out, int fsid_size, long *namelen_out, long *spare_out); +#endif + +struct hostfs_user_operations { + int (*stat_file)(const char *path, unsigned long long *inode_out, + int *mode_out, int *nlink_out, int *uid_out, int *gid_out, + unsigned long long *size_out, struct timespec *atime_out, + struct timespec *mtime_out, struct timespec *ctime_out, + int *blksize_out, unsigned long long *blocks_out); + int (*access_file)(char *path, int r, int w, int x); + int (*open_file)(char *path, int r, int w, int append); + int (*file_type)(const char *path, int *rdev); + void *(*open_dir)(char *path, int *err_out); + char *(*read_dir)(void *stream, unsigned long long *pos, + unsigned long long *ino_out, int *len_out); + void (*close_file)(void *stream); + void (*close_dir)(void *stream); + int (*read_file)(int fd, unsigned long long *offset, char *buf, int len); + int (*write_file)(int fd, unsigned long long *offset, const char *buf, + int len); + int (*lseek_file)(int fd, long long offset, int whence); + int (*file_create)(char *name, int ur, int uw, int ux, int gr, + int gw, int gx, int or, int ow, int ox); + int (*set_attr)(const char *file, struct hostfs_iattr *attrs); + int (*make_symlink)(const char *from, const char *to); + int (*unlink_file)(const char *file); + int (*do_mkdir)(const char *file, int mode); + int (*do_rmdir)(const char *file); + int (*do_mknod)(const char *file, int mode, int dev); + int (*link_file)(const char *from, const char *to); + int (*do_readlink)(char *file, char *buf, int size); + int (*rename_file)(char *from, char *to); + int (*do_statfs)(char *root, long *bsize_out, long long *blocks_out, + long long *bfree_out, long long *bavail_out, + long long *files_out, long long *ffree_out, + void *fsid_out, int fsid_size, long *namelen_out, + long *spare_out); +}; + +/* For now only one hostfs_user_operations can be registered */ +extern int register_hostfs_ops(struct hostfs_user_operations * ops); #endif --- ./fs/hostfs/hostfs_user.c.fix 2004-03-01 19:02:15.000000000 +0100 +++ ./fs/hostfs/hostfs_user.c 2004-03-01 19:25:04.000000000 +0100 @@ -341,6 +341,31 @@ return(0); } +static struct hostfs_user_operations host_ops = { + .stat_file = stat_file, + .file_type = file_type, + .access_file = access_file, + .open_file = open_file, + .open_dir = open_dir, + .read_dir = read_dir, + .read_file = read_file, + .write_file = write_file, + .lseek_file = lseek_file, + .close_file = close_file, + .close_dir = close_dir, + .file_create = file_create, + .set_attr = set_attr, + .make_symlink = make_symlink, + .unlink_file = unlink_file, + .do_mkdir = do_mkdir, + .do_rmdir = do_rmdir, + .do_mknod = do_mknod, + .link_file = link_file, + .do_readlink = do_readlink, + .rename_file = rename_file, + .do_statfs = do_statfs, +}; + /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically