📄 intermezzo_fs.h
字号:
/* upcall.c */#define SYNCHRONOUS 0#define ASYNCHRONOUS 1/* asynchronous calls */int izo_upc_kml(int minor, __u64 offset, __u32 first_recno, __u64 length, __u32 last_recno, char *fsetname);int izo_upc_kml_truncate(int minor, __u64 length, __u32 last_recno, char *fsetname);int izo_upc_go_fetch_kml(int minor, char *fsetname, uuid_t uuid, __u64 kmlsize);int izo_upc_backfetch(int minor, char *path, char *fileset, struct lento_vfs_context *);/* synchronous calls */int izo_upc_get_fileid(int minor, __u32 reclen, char *rec, __u32 pathlen, char *path, char *fsetname);int izo_upc_permit(int minor, struct dentry *, __u32 pathlen, char *path, char *fset);int izo_upc_open(int minor, __u32 pathlen, char *path, char *fsetname, struct lento_vfs_context *info);int izo_upc_connect(int minor, __u64 ip_address, __u64 port, __u8 uuid[16], int client_flag);int izo_upc_revoke_permit(int minor, char *fsetname, uuid_t uuid);int izo_upc_set_kmlsize(int minor, char *fsetname, uuid_t uuid, __u64 kmlsize);int izo_upc_client_make_branch(int minor, char *fsetname);int izo_upc_server_make_branch(int minor, char *fsetname);int izo_upc_branch_undo(int minor, char *fsetname, char *branchname);int izo_upc_branch_redo(int minor, char *fsetname, char *branchname);int izo_upc_repstatus(int minor, char * fsetname, struct izo_rcvd_rec *lr_server);/* general mechanism */int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *, int async);/* replicator.c */int izo_repstatus(struct presto_file_set *fset, __u64 client_kmlsize, struct izo_rcvd_rec *lr_client, struct izo_rcvd_rec *lr_server);int izo_rep_cache_init(struct presto_file_set *);loff_t izo_rcvd_get(struct izo_rcvd_rec *, struct presto_file_set *, char *uuid);loff_t izo_rcvd_write(struct presto_file_set *, struct izo_rcvd_rec *);loff_t izo_rcvd_upd_remote(struct presto_file_set *fset, char * uuid, __u64 remote_recno, __u64 remote_offset);/* sysctl.c */int init_intermezzo_sysctl(void);void cleanup_intermezzo_sysctl(void);/* ext_attr.c *//* We will be more tolerant than the default ea patch with attr name sizes and * the size of value. If these come via VFS from the default ea patches, the * corresponding character strings will be truncated anyway. During journalling- * we journal length for both name and value. See journal_set_ext_attr. */#define PRESTO_EXT_ATTR_NAME_MAX 128#define PRESTO_EXT_ATTR_VALUE_MAX 8192#define PRESTO_ALLOC(ptr, size) \do { \ long s = (size); \ (ptr) = kmalloc(s, GFP_KERNEL); \ if ((ptr) == NULL) \ CERROR("IZO: out of memory at %s:%d (trying to " \ "allocate %ld)\n", __FILE__, __LINE__, s); \ else { \ presto_kmem_inc((ptr), s); \ memset((ptr), 0, s); \ } \ CDEBUG(D_MALLOC, "kmalloced: %ld at %p (tot %ld).\n", \ s, (ptr), presto_kmemory); \} while (0)#define PRESTO_FREE(ptr, size) \do { \ long s = (size); \ if ((ptr) == NULL) { \ CERROR("IZO: free NULL pointer (%ld bytes) at " \ "%s:%d\n", s, __FILE__, __LINE__); \ break; \ } \ kfree(ptr); \ CDEBUG(D_MALLOC, "kfreed: %ld at %p (tot %ld).\n", \ s, (ptr), presto_kmemory); \ presto_kmem_dec((ptr), s); \} while (0)static inline int dentry_name_cmp(struct dentry *dentry, char *name){ return (strlen(name) == dentry->d_name.len && memcmp(name, dentry->d_name.name, dentry->d_name.len) == 0);}static inline char *strdup(char *str){ char *tmp; tmp = kmalloc(strlen(str) + 1, GFP_KERNEL); if (tmp) memcpy(tmp, str, strlen(str) + 1); return tmp;}/* buffer MUST be at least the size of izo_ioctl_hdr */static inline int izo_ioctl_getdata(char *buf, char *end, void *arg){ struct izo_ioctl_hdr *hdr; struct izo_ioctl_data *data; int err; ENTRY; hdr = (struct izo_ioctl_hdr *)buf; data = (struct izo_ioctl_data *)buf; err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); if ( err ) { EXIT; return err; } if (hdr->ioc_version != IZO_IOCTL_VERSION) { CERROR("IZO: version mismatch kernel vs application\n"); return -EINVAL; } if (hdr->ioc_len + buf >= end) { CERROR("IZO: user buffer exceeds kernel buffer\n"); return -EINVAL; } if (hdr->ioc_len < sizeof(struct izo_ioctl_data)) { CERROR("IZO: user buffer too small for ioctl\n"); return -EINVAL; } err = copy_from_user(buf, (void *)arg, hdr->ioc_len); if ( err ) { EXIT; return err; } if (izo_ioctl_is_invalid(data)) { CERROR("IZO: ioctl not correctly formatted\n"); return -EINVAL; } if (data->ioc_inllen1) { data->ioc_inlbuf1 = &data->ioc_bulk[0]; } if (data->ioc_inllen2) { data->ioc_inlbuf2 = &data->ioc_bulk[0] + size_round(data->ioc_inllen1); } EXIT; return 0;}# define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path))# define free kfree# define malloc(a) kmalloc(a, GFP_KERNEL)# define printf printkint kml_reint_rec(struct file *dir, struct izo_ioctl_data *data);int izo_get_fileid(struct file *dir, struct izo_ioctl_data *data);int izo_set_fileid(struct file *dir, struct izo_ioctl_data *data);#else /* __KERNEL__ */# include <stdlib.h># include <stdio.h># include <sys/types.h># include <sys/ioctl.h># include <string.h># define printk printf# ifndef CERROR# define CERROR printf# endif# define kmalloc(a,b) malloc(a)void init_fsreintdata (void);int kml_fsreint(struct kml_rec *rec, char *basedir);int kml_iocreint(__u32 size, char *ptr, __u32 offset, int dird, uuid_t uuid, __u32 generate_kml);static inline int izo_ioctl_packlen(struct izo_ioctl_data *data);static inline void izo_ioctl_init(struct izo_ioctl_data *data){ memset(data, 0, sizeof(*data)); data->ioc_len = sizeof(*data); data->ioc_version = IZO_IOCTL_VERSION;}static inline intizo_ioctl_pack(struct izo_ioctl_data *data, char **pbuf, int max){ char *ptr; struct izo_ioctl_data *overlay; data->ioc_len = izo_ioctl_packlen(data); data->ioc_version = IZO_IOCTL_VERSION; if (*pbuf && izo_ioctl_packlen(data) > max) return 1; if (*pbuf == NULL) *pbuf = malloc(data->ioc_len); if (*pbuf == NULL) return 1; overlay = (struct izo_ioctl_data *)*pbuf; memcpy(*pbuf, data, sizeof(*data)); ptr = overlay->ioc_bulk; if (data->ioc_inlbuf1) LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr); if (data->ioc_inlbuf2) LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr); if (izo_ioctl_is_invalid(overlay)) return 1; return 0;}#endif /* __KERNEL__*/#define IZO_ERROR_NAME 1#define IZO_ERROR_UPDATE 2#define IZO_ERROR_DELETE 3#define IZO_ERROR_RENAME 4static inline char *izo_error(int err){#ifndef __KERNEL__ if (err <= 0) return strerror(-err);#endif switch (err) { case IZO_ERROR_NAME: return "InterMezzo name/name conflict"; case IZO_ERROR_UPDATE: return "InterMezzo update/update conflict"; case IZO_ERROR_DELETE: return "InterMezzo update/delete conflict"; case IZO_ERROR_RENAME: return "InterMezzo rename/rename conflict"; } return "Unknown InterMezzo error";}static inline int izo_ioctl_packlen(struct izo_ioctl_data *data){ int len = sizeof(struct izo_ioctl_data); len += size_round(data->ioc_inllen1); len += size_round(data->ioc_inllen2); return len;}static inline int izo_ioctl_is_invalid(struct izo_ioctl_data *data){ if (data->ioc_len > (1<<30)) { CERROR("IZO ioctl: ioc_len larger than 1<<30\n"); return 1; } if (data->ioc_inllen1 > (1<<30)) { CERROR("IZO ioctl: ioc_inllen1 larger than 1<<30\n"); return 1; } if (data->ioc_inllen2 > (1<<30)) { CERROR("IZO ioctl: ioc_inllen2 larger than 1<<30\n"); return 1; } if (data->ioc_inlbuf1 && !data->ioc_inllen1) { CERROR("IZO ioctl: inlbuf1 pointer but 0 length\n"); return 1; } if (data->ioc_inlbuf2 && !data->ioc_inllen2) { CERROR("IZO ioctl: inlbuf2 pointer but 0 length\n"); return 1; } if (data->ioc_pbuf1 && !data->ioc_plen1) { CERROR("IZO ioctl: pbuf1 pointer but 0 length\n"); return 1; } if (data->ioc_pbuf2 && !data->ioc_plen2) { CERROR("IZO ioctl: pbuf2 pointer but 0 length\n"); return 1; } if (izo_ioctl_packlen(data) != data->ioc_len ) { CERROR("IZO ioctl: packlen exceeds ioc_len\n"); return 1; } if (data->ioc_inllen1 && data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') { CERROR("IZO ioctl: inlbuf1 not 0 terminated\n"); return 1; } if (data->ioc_inllen2 && data->ioc_bulk[size_round(data->ioc_inllen1) + data->ioc_inllen2 - 1] != '\0') { CERROR("IZO ioctl: inlbuf2 not 0 terminated\n"); return 1; } return 0;}/* kml_unpack.c */char *kml_print_rec(struct kml_rec *rec, int brief);int kml_unpack(struct kml_rec *rec, char **buf, char *end);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -