Skip to content

Commit b42d570

Browse files
author
Al Viro
committed
afs: get rid of junk in fs/afs/proc.c
kill pointless method instances and don't bother with ->owner - it's ignored for procfs files anyway, make use of remove_proc_subtree() for removal, get rid of cell->proc_dir. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 479e64c commit b42d570

2 files changed

Lines changed: 22 additions & 101 deletions

File tree

‎fs/afs/internal.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ struct afs_cell {
195195
struct list_head link; /* main cell list link */
196196
struct key *anonymous_key; /* anonymous user key for this cell */
197197
struct list_head proc_link; /* /proc cell list link */
198-
struct proc_dir_entry *proc_dir; /* /proc dir for this cell */
199198
#ifdef CONFIG_AFS_FSCACHE
200199
struct fscache_cookie *cache; /* caching cookie */
201200
#endif

‎fs/afs/proc.c‎

Lines changed: 22 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,21 @@ static const struct file_operations afs_proc_cells_fops = {
4141
.write = afs_proc_cells_write,
4242
.llseek = seq_lseek,
4343
.release = seq_release,
44-
.owner = THIS_MODULE,
4544
};
4645

47-
static int afs_proc_rootcell_open(struct inode *inode, struct file *file);
48-
static int afs_proc_rootcell_release(struct inode *inode, struct file *file);
4946
static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
5047
size_t size, loff_t *_pos);
5148
static ssize_t afs_proc_rootcell_write(struct file *file,
5249
const char __user *buf,
5350
size_t size, loff_t *_pos);
5451

5552
static const struct file_operations afs_proc_rootcell_fops = {
56-
.open = afs_proc_rootcell_open,
5753
.read = afs_proc_rootcell_read,
5854
.write = afs_proc_rootcell_write,
5955
.llseek = no_llseek,
60-
.release = afs_proc_rootcell_release,
61-
.owner = THIS_MODULE,
6256
};
6357

6458
static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file);
65-
static int afs_proc_cell_volumes_release(struct inode *inode,
66-
struct file *file);
6759
static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);
6860
static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
6961
loff_t *pos);
@@ -81,14 +73,11 @@ static const struct file_operations afs_proc_cell_volumes_fops = {
8173
.open = afs_proc_cell_volumes_open,
8274
.read = seq_read,
8375
.llseek = seq_lseek,
84-
.release = afs_proc_cell_volumes_release,
85-
.owner = THIS_MODULE,
76+
.release = seq_release,
8677
};
8778

8879
static int afs_proc_cell_vlservers_open(struct inode *inode,
8980
struct file *file);
90-
static int afs_proc_cell_vlservers_release(struct inode *inode,
91-
struct file *file);
9281
static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);
9382
static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
9483
loff_t *pos);
@@ -106,13 +95,10 @@ static const struct file_operations afs_proc_cell_vlservers_fops = {
10695
.open = afs_proc_cell_vlservers_open,
10796
.read = seq_read,
10897
.llseek = seq_lseek,
109-
.release = afs_proc_cell_vlservers_release,
110-
.owner = THIS_MODULE,
98+
.release = seq_release,
11199
};
112100

113101
static int afs_proc_cell_servers_open(struct inode *inode, struct file *file);
114-
static int afs_proc_cell_servers_release(struct inode *inode,
115-
struct file *file);
116102
static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos);
117103
static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
118104
loff_t *pos);
@@ -130,38 +116,29 @@ static const struct file_operations afs_proc_cell_servers_fops = {
130116
.open = afs_proc_cell_servers_open,
131117
.read = seq_read,
132118
.llseek = seq_lseek,
133-
.release = afs_proc_cell_servers_release,
134-
.owner = THIS_MODULE,
119+
.release = seq_release,
135120
};
136121

137122
/*
138123
* initialise the /proc/fs/afs/ directory
139124
*/
140125
int afs_proc_init(void)
141126
{
142-
struct proc_dir_entry *p;
143-
144127
_enter("");
145128

146129
proc_afs = proc_mkdir("fs/afs", NULL);
147130
if (!proc_afs)
148131
goto error_dir;
149132

150-
p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
151-
if (!p)
152-
goto error_cells;
153-
154-
p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
155-
if (!p)
156-
goto error_rootcell;
133+
if (!proc_create("cells", 0, proc_afs, &afs_proc_cells_fops) ||
134+
!proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops))
135+
goto error_tree;
157136

158137
_leave(" = 0");
159138
return 0;
160139

161-
error_rootcell:
162-
remove_proc_entry("cells", proc_afs);
163-
error_cells:
164-
remove_proc_entry("fs/afs", NULL);
140+
error_tree:
141+
remove_proc_subtree("fs/afs", NULL);
165142
error_dir:
166143
_leave(" = -ENOMEM");
167144
return -ENOMEM;
@@ -172,9 +149,7 @@ int afs_proc_init(void)
172149
*/
173150
void afs_proc_cleanup(void)
174151
{
175-
remove_proc_entry("rootcell", proc_afs);
176-
remove_proc_entry("cells", proc_afs);
177-
remove_proc_entry("fs/afs", NULL);
152+
remove_proc_subtree("fs/afs", NULL);
178153
}
179154

180155
/*
@@ -319,19 +294,6 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
319294
goto done;
320295
}
321296

322-
/*
323-
* Stubs for /proc/fs/afs/rootcell
324-
*/
325-
static int afs_proc_rootcell_open(struct inode *inode, struct file *file)
326-
{
327-
return 0;
328-
}
329-
330-
static int afs_proc_rootcell_release(struct inode *inode, struct file *file)
331-
{
332-
return 0;
333-
}
334-
335297
static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
336298
size_t size, loff_t *_pos)
337299
{
@@ -387,38 +349,27 @@ static ssize_t afs_proc_rootcell_write(struct file *file,
387349
*/
388350
int afs_proc_cell_setup(struct afs_cell *cell)
389351
{
390-
struct proc_dir_entry *p;
352+
struct proc_dir_entry *dir;
391353

392354
_enter("%p{%s}", cell, cell->name);
393355

394-
cell->proc_dir = proc_mkdir(cell->name, proc_afs);
395-
if (!cell->proc_dir)
356+
dir = proc_mkdir(cell->name, proc_afs);
357+
if (!dir)
396358
goto error_dir;
397359

398-
p = proc_create_data("servers", 0, cell->proc_dir,
399-
&afs_proc_cell_servers_fops, cell);
400-
if (!p)
401-
goto error_servers;
402-
403-
p = proc_create_data("vlservers", 0, cell->proc_dir,
404-
&afs_proc_cell_vlservers_fops, cell);
405-
if (!p)
406-
goto error_vlservers;
407-
408-
p = proc_create_data("volumes", 0, cell->proc_dir,
409-
&afs_proc_cell_volumes_fops, cell);
410-
if (!p)
411-
goto error_volumes;
360+
if (!proc_create_data("servers", 0, dir,
361+
&afs_proc_cell_servers_fops, cell) ||
362+
!proc_create_data("vlservers", 0, dir,
363+
&afs_proc_cell_vlservers_fops, cell) ||
364+
!proc_create_data("volumes", 0, dir,
365+
&afs_proc_cell_volumes_fops, cell))
366+
goto error_tree;
412367

413368
_leave(" = 0");
414369
return 0;
415370

416-
error_volumes:
417-
remove_proc_entry("vlservers", cell->proc_dir);
418-
error_vlservers:
419-
remove_proc_entry("servers", cell->proc_dir);
420-
error_servers:
421-
remove_proc_entry(cell->name, proc_afs);
371+
error_tree:
372+
remove_proc_subtree(cell->name, proc_afs);
422373
error_dir:
423374
_leave(" = -ENOMEM");
424375
return -ENOMEM;
@@ -431,10 +382,7 @@ void afs_proc_cell_remove(struct afs_cell *cell)
431382
{
432383
_enter("");
433384

434-
remove_proc_entry("volumes", cell->proc_dir);
435-
remove_proc_entry("vlservers", cell->proc_dir);
436-
remove_proc_entry("servers", cell->proc_dir);
437-
remove_proc_entry(cell->name, proc_afs);
385+
remove_proc_subtree(cell->name, proc_afs);
438386

439387
_leave("");
440388
}
@@ -462,14 +410,6 @@ static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file)
462410
return 0;
463411
}
464412

465-
/*
466-
* close the file and release the ref to the cell
467-
*/
468-
static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file)
469-
{
470-
return seq_release(inode, file);
471-
}
472-
473413
/*
474414
* set up the iterator to start reading from the cells list and return the
475415
* first item
@@ -568,15 +508,6 @@ static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file)
568508
return 0;
569509
}
570510

571-
/*
572-
* close the file and release the ref to the cell
573-
*/
574-
static int afs_proc_cell_vlservers_release(struct inode *inode,
575-
struct file *file)
576-
{
577-
return seq_release(inode, file);
578-
}
579-
580511
/*
581512
* set up the iterator to start reading from the cells list and return the
582513
* first item
@@ -672,15 +603,6 @@ static int afs_proc_cell_servers_open(struct inode *inode, struct file *file)
672603
return 0;
673604
}
674605

675-
/*
676-
* close the file and release the ref to the cell
677-
*/
678-
static int afs_proc_cell_servers_release(struct inode *inode,
679-
struct file *file)
680-
{
681-
return seq_release(inode, file);
682-
}
683-
684606
/*
685607
* set up the iterator to start reading from the cells list and return the
686608
* first item

0 commit comments

Comments
 (0)