Skip to content

Commit e331f60

Browse files
author
J. Bruce Fields
committed
nfsd: fail init on /proc/fs/nfs/exports creation failure
I assume the reason failure of creation was ignored here was just to continue support embedded systems that want nfsd but not proc. However, in cases where proc is supported it would be clearer to fail entirely than to come up with some features disabled. Acked-by: NeilBrown <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 440bcc5 commit e331f60

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

fs/nfsd/nfsctl.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,27 @@ static struct file_system_type nfsd_fs_type = {
674674
.kill_sb = kill_litter_super,
675675
};
676676

677+
#ifdef CONFIG_PROC_FS
678+
static int create_proc_exports_entry(void)
679+
{
680+
struct proc_dir_entry *entry;
681+
682+
entry = proc_mkdir("fs/nfs", NULL);
683+
if (!entry)
684+
return -ENOMEM;
685+
entry = create_proc_entry("fs/nfs/exports", 0, NULL);
686+
if (!entry)
687+
return -ENOMEM;
688+
entry->proc_fops = &exports_operations;
689+
return 0;
690+
}
691+
#else /* CONFIG_PROC_FS */
692+
static int create_proc_exports_entry(void)
693+
{
694+
return 0;
695+
}
696+
#endif
697+
677698
static int __init init_nfsd(void)
678699
{
679700
int retval;
@@ -689,23 +710,21 @@ static int __init init_nfsd(void)
689710
nfsd_export_init(); /* Exports table */
690711
nfsd_lockd_init(); /* lockd->nfsd callbacks */
691712
nfsd_idmap_init(); /* Name to ID mapping */
692-
if (proc_mkdir("fs/nfs", NULL)) {
693-
struct proc_dir_entry *entry;
694-
entry = create_proc_entry("fs/nfs/exports", 0, NULL);
695-
if (entry)
696-
entry->proc_fops = &exports_operations;
697-
}
713+
retval = create_proc_exports_entry();
714+
if (retval)
715+
goto out_free_idmap;
698716
retval = register_filesystem(&nfsd_fs_type);
699717
if (retval)
700718
goto out_free_all;
701719
return 0;
702720
out_free_all:
703-
nfsd_idmap_shutdown();
704-
nfsd_export_shutdown();
705-
nfsd_reply_cache_shutdown();
706721
remove_proc_entry("fs/nfs/exports", NULL);
707722
remove_proc_entry("fs/nfs", NULL);
723+
nfsd_idmap_shutdown();
724+
out_free_idmap:
708725
nfsd_lockd_shutdown();
726+
nfsd_export_shutdown();
727+
nfsd_reply_cache_shutdown();
709728
out_free_stat:
710729
nfsd_stat_shutdown();
711730
nfsd4_free_slabs();

0 commit comments

Comments
 (0)