diff options
Diffstat (limited to 'fs/afs/proc.c')
| -rw-r--r-- | fs/afs/proc.c | 122 | 
1 files changed, 22 insertions, 100 deletions
diff --git a/fs/afs/proc.c b/fs/afs/proc.c index 526e4bbbde5..24a905b076f 100644 --- a/fs/afs/proc.c +++ b/fs/afs/proc.c @@ -41,11 +41,8 @@ static const struct file_operations afs_proc_cells_fops = {  	.write		= afs_proc_cells_write,  	.llseek		= seq_lseek,  	.release	= seq_release, -	.owner		= THIS_MODULE,  }; -static int afs_proc_rootcell_open(struct inode *inode, struct file *file); -static int afs_proc_rootcell_release(struct inode *inode, struct file *file);  static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,  				      size_t size, loff_t *_pos);  static ssize_t afs_proc_rootcell_write(struct file *file, @@ -53,17 +50,12 @@ static ssize_t afs_proc_rootcell_write(struct file *file,  				       size_t size, loff_t *_pos);  static const struct file_operations afs_proc_rootcell_fops = { -	.open		= afs_proc_rootcell_open,  	.read		= afs_proc_rootcell_read,  	.write		= afs_proc_rootcell_write,  	.llseek		= no_llseek, -	.release	= afs_proc_rootcell_release, -	.owner		= THIS_MODULE,  };  static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file); -static int afs_proc_cell_volumes_release(struct inode *inode, -					 struct file *file);  static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);  static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,  					loff_t *pos); @@ -81,14 +73,11 @@ static const struct file_operations afs_proc_cell_volumes_fops = {  	.open		= afs_proc_cell_volumes_open,  	.read		= seq_read,  	.llseek		= seq_lseek, -	.release	= afs_proc_cell_volumes_release, -	.owner		= THIS_MODULE, +	.release	= seq_release,  };  static int afs_proc_cell_vlservers_open(struct inode *inode,  					struct file *file); -static int afs_proc_cell_vlservers_release(struct inode *inode, -					   struct file *file);  static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);  static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,  					  loff_t *pos); @@ -106,13 +95,10 @@ static const struct file_operations afs_proc_cell_vlservers_fops = {  	.open		= afs_proc_cell_vlservers_open,  	.read		= seq_read,  	.llseek		= seq_lseek, -	.release	= afs_proc_cell_vlservers_release, -	.owner		= THIS_MODULE, +	.release	= seq_release,  };  static int afs_proc_cell_servers_open(struct inode *inode, struct file *file); -static int afs_proc_cell_servers_release(struct inode *inode, -					 struct file *file);  static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos);  static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,  					loff_t *pos); @@ -130,8 +116,7 @@ static const struct file_operations afs_proc_cell_servers_fops = {  	.open		= afs_proc_cell_servers_open,  	.read		= seq_read,  	.llseek		= seq_lseek, -	.release	= afs_proc_cell_servers_release, -	.owner		= THIS_MODULE, +	.release	= seq_release,  };  /* @@ -139,29 +124,21 @@ static const struct file_operations afs_proc_cell_servers_fops = {   */  int afs_proc_init(void)  { -	struct proc_dir_entry *p; -  	_enter("");  	proc_afs = proc_mkdir("fs/afs", NULL);  	if (!proc_afs)  		goto error_dir; -	p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops); -	if (!p) -		goto error_cells; - -	p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops); -	if (!p) -		goto error_rootcell; +	if (!proc_create("cells", 0644, proc_afs, &afs_proc_cells_fops) || +	    !proc_create("rootcell", 0644, proc_afs, &afs_proc_rootcell_fops)) +		goto error_tree;  	_leave(" = 0");  	return 0; -error_rootcell: - 	remove_proc_entry("cells", proc_afs); -error_cells: -	remove_proc_entry("fs/afs", NULL); +error_tree: +	remove_proc_subtree("fs/afs", NULL);  error_dir:  	_leave(" = -ENOMEM");  	return -ENOMEM; @@ -172,9 +149,7 @@ error_dir:   */  void afs_proc_cleanup(void)  { -	remove_proc_entry("rootcell", proc_afs); -	remove_proc_entry("cells", proc_afs); -	remove_proc_entry("fs/afs", NULL); +	remove_proc_subtree("fs/afs", NULL);  }  /* @@ -319,19 +294,6 @@ inval:  	goto done;  } -/* - * Stubs for /proc/fs/afs/rootcell - */ -static int afs_proc_rootcell_open(struct inode *inode, struct file *file) -{ -	return 0; -} - -static int afs_proc_rootcell_release(struct inode *inode, struct file *file) -{ -	return 0; -} -  static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,  				      size_t size, loff_t *_pos)  { @@ -387,38 +349,27 @@ nomem:   */  int afs_proc_cell_setup(struct afs_cell *cell)  { -	struct proc_dir_entry *p; +	struct proc_dir_entry *dir;  	_enter("%p{%s}", cell, cell->name); -	cell->proc_dir = proc_mkdir(cell->name, proc_afs); -	if (!cell->proc_dir) +	dir = proc_mkdir(cell->name, proc_afs); +	if (!dir)  		goto error_dir; -	p = proc_create_data("servers", 0, cell->proc_dir, -			     &afs_proc_cell_servers_fops, cell); -	if (!p) -		goto error_servers; - -	p = proc_create_data("vlservers", 0, cell->proc_dir, -			     &afs_proc_cell_vlservers_fops, cell); -	if (!p) -		goto error_vlservers; - -	p = proc_create_data("volumes", 0, cell->proc_dir, -			     &afs_proc_cell_volumes_fops, cell); -	if (!p) -		goto error_volumes; +	if (!proc_create_data("servers", 0, dir, +			     &afs_proc_cell_servers_fops, cell) || +	    !proc_create_data("vlservers", 0, dir, +			     &afs_proc_cell_vlservers_fops, cell) || +	    !proc_create_data("volumes", 0, dir, +			     &afs_proc_cell_volumes_fops, cell)) +		goto error_tree;  	_leave(" = 0");  	return 0; -error_volumes: -	remove_proc_entry("vlservers", cell->proc_dir); -error_vlservers: -	remove_proc_entry("servers", cell->proc_dir); -error_servers: -	remove_proc_entry(cell->name, proc_afs); +error_tree: +	remove_proc_subtree(cell->name, proc_afs);  error_dir:  	_leave(" = -ENOMEM");  	return -ENOMEM; @@ -431,10 +382,7 @@ void afs_proc_cell_remove(struct afs_cell *cell)  {  	_enter(""); -	remove_proc_entry("volumes", cell->proc_dir); -	remove_proc_entry("vlservers", cell->proc_dir); -	remove_proc_entry("servers", cell->proc_dir); -	remove_proc_entry(cell->name, proc_afs); +	remove_proc_subtree(cell->name, proc_afs);  	_leave("");  } @@ -463,14 +411,6 @@ static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file)  }  /* - * close the file and release the ref to the cell - */ -static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file) -{ -	return seq_release(inode, file); -} - -/*   * set up the iterator to start reading from the cells list and return the   * first item   */ @@ -569,15 +509,6 @@ static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file)  }  /* - * close the file and release the ref to the cell - */ -static int afs_proc_cell_vlservers_release(struct inode *inode, -					   struct file *file) -{ -	return seq_release(inode, file); -} - -/*   * set up the iterator to start reading from the cells list and return the   * first item   */ @@ -673,15 +604,6 @@ static int afs_proc_cell_servers_open(struct inode *inode, struct file *file)  }  /* - * close the file and release the ref to the cell - */ -static int afs_proc_cell_servers_release(struct inode *inode, -					 struct file *file) -{ -	return seq_release(inode, file); -} - -/*   * set up the iterator to start reading from the cells list and return the   * first item   */  | 
