]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/autofs4/inode.c
[PATCH] autofs4: add a show mount options for proc filesystem
[linux-2.6-omap-h63xx.git] / fs / autofs4 / inode.c
index 2d3082854a292dec3fc1ad749b81b9c700a4addb..d9a71dab40fc12c45b3c728ddbc6e9055eb9ac1a 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/file.h>
+#include <linux/seq_file.h>
 #include <linux/pagemap.h>
 #include <linux/parser.h>
 #include <linux/bitops.h>
@@ -46,6 +47,7 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
        ino->size = 0;
 
        ino->last_used = jiffies;
+       atomic_set(&ino->count, 0);
 
        ino->sbi = sbi;
 
@@ -64,10 +66,19 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
 
 void autofs4_free_ino(struct autofs_info *ino)
 {
+       struct autofs_info *p_ino;
+
        if (ino->dentry) {
                ino->dentry->d_fsdata = NULL;
-               if (ino->dentry->d_inode)
+               if (ino->dentry->d_inode) {
+                       struct dentry *parent = ino->dentry->d_parent;
+                       if (atomic_dec_and_test(&ino->count)) {
+                               p_ino = autofs4_dentry_ino(parent);
+                               if (p_ino && parent != ino->dentry)
+                                       atomic_dec(&p_ino->count);
+                       }
                        dput(ino->dentry);
+               }
                ino->dentry = NULL;
        }
        if (ino->free)
@@ -153,9 +164,26 @@ static void autofs4_put_super(struct super_block *sb)
        DPRINTK("shutting down");
 }
 
+static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(mnt->mnt_sb);
+
+       if (!sbi)
+               return 0;
+
+       seq_printf(m, ",fd=%d", sbi->pipefd);
+       seq_printf(m, ",pgrp=%d", sbi->oz_pgrp);
+       seq_printf(m, ",timeout=%lu", sbi->exp_timeout/HZ);
+       seq_printf(m, ",minproto=%d", sbi->min_proto);
+       seq_printf(m, ",maxproto=%d", sbi->max_proto);
+
+       return 0;
+}
+
 static struct super_operations autofs4_sops = {
        .put_super      = autofs4_put_super,
        .statfs         = simple_statfs,
+       .show_options   = autofs4_show_options,
 };
 
 enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto};
@@ -251,7 +279,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
        int pipefd;
        struct autofs_sb_info *sbi;
        struct autofs_info *ino;
-       int minproto, maxproto;
 
        sbi = (struct autofs_sb_info *) kmalloc(sizeof(*sbi), GFP_KERNEL);
        if ( !sbi )
@@ -263,13 +290,16 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
        s->s_fs_info = sbi;
        sbi->magic = AUTOFS_SBI_MAGIC;
        sbi->root = NULL;
+       sbi->pipefd = -1;
        sbi->catatonic = 0;
        sbi->exp_timeout = 0;
        sbi->oz_pgrp = process_group(current);
        sbi->sb = s;
        sbi->version = 0;
        sbi->sub_version = 0;
-       init_MUTEX(&sbi->wq_sem);
+       sbi->min_proto = 0;
+       sbi->max_proto = 0;
+       mutex_init(&sbi->wq_mutex);
        spin_lock_init(&sbi->fs_lock);
        sbi->queues = NULL;
        s->s_blocksize = 1024;
@@ -301,22 +331,26 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
        if (parse_options(data, &pipefd,
                          &root_inode->i_uid, &root_inode->i_gid,
                          &sbi->oz_pgrp,
-                         &minproto, &maxproto)) {
+                         &sbi->min_proto, &sbi->max_proto)) {
                printk("autofs: called with bogus options\n");
                goto fail_dput;
        }
 
        /* Couldn't this be tested earlier? */
-       if (maxproto < AUTOFS_MIN_PROTO_VERSION ||
-           minproto > AUTOFS_MAX_PROTO_VERSION) {
+       if (sbi->max_proto < AUTOFS_MIN_PROTO_VERSION ||
+           sbi->min_proto > AUTOFS_MAX_PROTO_VERSION) {
                printk("autofs: kernel does not match daemon version "
                       "daemon (%d, %d) kernel (%d, %d)\n",
-                       minproto, maxproto,
+                       sbi->min_proto, sbi->max_proto,
                        AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION);
                goto fail_dput;
        }
 
-       sbi->version = maxproto > AUTOFS_MAX_PROTO_VERSION ? AUTOFS_MAX_PROTO_VERSION : maxproto;
+       /* Establish highest kernel protocol version */
+       if (sbi->max_proto > AUTOFS_MAX_PROTO_VERSION)
+               sbi->version = AUTOFS_MAX_PROTO_VERSION;
+       else
+               sbi->version = sbi->max_proto;
        sbi->sub_version = AUTOFS_PROTO_SUBVERSION;
 
        DPRINTK("pipe fd = %d, pgrp = %u", pipefd, sbi->oz_pgrp);
@@ -329,6 +363,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
        if ( !pipe->f_op || !pipe->f_op->write )
                goto fail_fput;
        sbi->pipe = pipe;
+       sbi->pipefd = pipefd;
 
        /*
         * Take a reference to the root dentry so we get a chance to