X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Fparams_tree.h;h=92bd566ca2853439dd26bcf6912c977c82ee9bb9;hp=41413eb0fe0ad88c93475bbcc2aef1f49043e81d;hb=5655ee76f5c7573c9ad076a92df6388f27b65196;hpb=663ef6abd788c3388cae8d5bc5421bad99979c8b diff --git a/libcfs/include/libcfs/params_tree.h b/libcfs/include/libcfs/params_tree.h index 41413eb..92bd566 100644 --- a/libcfs/include/libcfs/params_tree.h +++ b/libcfs/include/libcfs/params_tree.h @@ -48,33 +48,7 @@ #endif #ifdef LPROCFS -typedef struct file cfs_param_file_t; -typedef struct inode cfs_inode_t; -typedef struct proc_inode cfs_proc_inode_t; -typedef struct seq_file cfs_seq_file_t; -typedef struct seq_operations cfs_seq_ops_t; -typedef struct file_operations cfs_param_file_ops_t; -typedef cfs_module_t *cfs_param_module_t; -typedef struct proc_dir_entry cfs_param_dentry_t; -typedef struct poll_table_struct cfs_poll_table_t; -#define CFS_PARAM_MODULE THIS_MODULE -#define CFS_PDE(value) PDE(value) -#define cfs_file_private(file) (file->private_data) -#define cfs_dentry_data(dentry) (dentry->data) -#define cfs_proc_inode_pde(proc_inode) (proc_inode->pde) -#define cfs_proc_inode(proc_inode) (proc_inode->vfs_inode) -#define cfs_seq_read_common seq_read -#define cfs_seq_lseek_common seq_lseek -#define cfs_seq_private(seq) (seq->private) -#define cfs_seq_printf(seq, format, ...) seq_printf(seq, format, \ - ## __VA_ARGS__) -#define cfs_seq_release(inode, file) seq_release(inode, file) -#define cfs_seq_puts(seq, s) seq_puts(seq, s) -#define cfs_seq_putc(seq, s) seq_putc(seq, s) -#define cfs_seq_read(file, buf, count, ppos, rc) (rc = seq_read(file, buf, \ - count, ppos)) -#define cfs_seq_open(file, ops, rc) (rc = seq_open(file, ops)) - +#ifndef HAVE_ONLY_PROCFS_SEQ /* in lprocfs_stat.c, to protect the private data for proc entries */ extern struct rw_semaphore _lprocfs_lock; @@ -110,105 +84,117 @@ do { \ do { \ up_write(&_lprocfs_lock); \ } while(0) + +#define PDE_DATA(inode) PDE(inode)->data + +#else /* New proc api */ + +static inline struct proc_dir_entry *PDE(struct inode *inode) +{ + return NULL; +} + +static inline +int LPROCFS_ENTRY_CHECK(struct proc_dir_entry *dp) +{ + return 0; +} + +#define LPROCFS_WRITE_ENTRY() do {} while(0) +#define LPROCFS_WRITE_EXIT() do {} while(0) + +#endif + #else /* !LPROCFS */ -typedef struct cfs_params_file { - void *param_private; - loff_t param_pos; - unsigned int param_flags; -} cfs_param_file_t; - -typedef struct cfs_param_inode { - void *param_private; -} cfs_inode_t; - -typedef struct cfs_param_dentry { - void *param_data; -} cfs_param_dentry_t; - -typedef struct cfs_proc_inode { - cfs_param_dentry_t *param_pde; - cfs_inode_t param_inode; -} cfs_proc_inode_t; - -struct cfs_seq_operations; -typedef struct cfs_seq_file { - char *buf; - size_t size; - size_t from; - size_t count; - loff_t index; - loff_t version; +struct file { + void *param_private; + loff_t param_pos; + unsigned int param_flags; +}; + +struct inode { + void *param_private; +}; + +struct poll_table_struct { + void *pad; +}; + +struct proc_dir_entry { + void *param_data; +}; + +struct proc_inode { + struct proc_dir_entry *param_pde; + struct inode param_inode; +}; + +struct seq_operations; +struct seq_file { + char *buf; + size_t size; + size_t from; + size_t count; + loff_t index; + loff_t version; struct mutex lock; - struct cfs_seq_operations *op; - void *private; -} cfs_seq_file_t; - -typedef struct cfs_seq_operations { - void *(*start) (cfs_seq_file_t *m, loff_t *pos); - void (*stop) (cfs_seq_file_t *m, void *v); - void *(*next) (cfs_seq_file_t *m, void *v, loff_t *pos); - int (*show) (cfs_seq_file_t *m, void *v); -} cfs_seq_ops_t; - -typedef void *cfs_param_module_t; -typedef void *cfs_poll_table_t; - -typedef struct cfs_param_file_ops { - cfs_param_module_t owner; - int (*open) (cfs_inode_t *, struct file *); - loff_t (*llseek)(struct file *, loff_t, int); - int (*release) (cfs_inode_t *, cfs_param_file_t *); - unsigned int (*poll) (struct file *, cfs_poll_table_t *); - ssize_t (*write) (struct file *, const char *, size_t, loff_t *); - ssize_t (*read)(struct file *, char *, size_t, loff_t *); -} cfs_param_file_ops_t; -typedef cfs_param_file_ops_t *cfs_lproc_filep_t; - -static inline cfs_proc_inode_t *FAKE_PROC_I(const cfs_inode_t *inode) + const struct seq_operations *op; + void *private; +}; + +struct seq_operations { + void *(*start) (struct seq_file *m, loff_t *pos); + void (*stop) (struct seq_file *m, void *v); + void *(*next) (struct seq_file *m, void *v, loff_t *pos); + int (*show) (struct seq_file *m, void *v); +}; + +#define seq_lseek NULL + +static inline int seq_read(char *buf, size_t count, loff_t *ppos) { - return container_of(inode, cfs_proc_inode_t, param_inode); + return 0; } -static inline cfs_param_dentry_t *FAKE_PDE(cfs_inode_t *inode) +static inline int +seq_open(struct file *file, const struct seq_operations *fops) { - return FAKE_PROC_I(inode)->param_pde; + struct seq_file *p = file->param_private; + + if (p == NULL) { + LIBCFS_ALLOC(p, sizeof(*p)); + if (p == NULL) + return -ENOMEM; + file->param_private = p; + } else { + memset(p, 0, sizeof(*p)); + } + p->op = fops; + return 0; } -#define CFS_PARAM_MODULE NULL -#define CFS_PDE(value) FAKE_PDE(value) -#define cfs_file_private(file) (file->param_private) -#define cfs_dentry_data(dentry) (dentry->param_data) -#define cfs_proc_inode(proc_inode) (proc_inode->param_inode) -#define cfs_proc_inode_pde(proc_inode) (proc_inode->param_pde) -#define cfs_seq_read_common NULL -#define cfs_seq_lseek_common NULL -#define cfs_seq_private(seq) (seq->private) -#define cfs_seq_read(file, buf, count, ppos, rc) do {} while(0) -#define cfs_seq_open(file, ops, rc) \ -do { \ - cfs_seq_file_t *p = cfs_file_private(file); \ - if (!p) { \ - LIBCFS_ALLOC(p, sizeof(*p)); \ - if (!p) { \ - rc = -ENOMEM; \ - break; \ - } \ - cfs_file_private(file) = p; \ - } \ - memset(p, 0, sizeof(*p)); \ - p->op = ops; \ - rc = 0; \ -} while(0) +static inline struct proc_inode *FAKE_PROC_I(const struct inode *inode) +{ + return container_of(inode, struct proc_inode, param_inode); +} + +static inline struct proc_dir_entry *PDE(struct inode *inode) +{ + return FAKE_PROC_I(inode)->param_pde; +} static inline -int LPROCFS_ENTRY_CHECK(cfs_param_dentry_t *dp) +int LPROCFS_ENTRY_CHECK(struct proc_dir_entry *dp) { - return 0; + return 0; } #define LPROCFS_WRITE_ENTRY() do {} while(0) #define LPROCFS_WRITE_EXIT() do {} while(0) +int seq_printf(struct seq_file *, const char *, ...) + __attribute__ ((format (printf,2,3))); + #endif /* LPROCFS */ /* XXX: params_tree APIs */