Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libperfuse Mont FUSE filesystem with proprer source and ...



details:   https://anonhg.NetBSD.org/src/rev/cb2f0320a816
branches:  trunk
changeset: 764931:cb2f0320a816
user:      manu <manu%NetBSD.org@localhost>
date:      Thu May 12 10:32:41 2011 +0000

description:
Mont FUSE filesystem with proprer source and fstype so that df and mount
display something that makes sense

diffstat:

 lib/libperfuse/perfuse.c |  37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r 570d0adfb9e0 -r cb2f0320a816 lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c  Thu May 12 08:42:24 2011 +0000
+++ b/lib/libperfuse/perfuse.c  Thu May 12 10:32:41 2011 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.12 2011/04/25 04:54:53 manu Exp $ */
+/*  $NetBSD: perfuse.c,v 1.13 2011/05/12 10:32:41 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -391,7 +391,8 @@
        struct perfuse_state *ps;
        struct puffs_usermount *pu;
        struct puffs_ops *pops;
-       char name[] = "perfuse";
+       const char *source = _PATH_PUFFS;
+       char *fstype;
        unsigned int puffs_flags;
        struct puffs_node *pn_root;
        struct puffs_pathobj *po_root;
@@ -399,11 +400,33 @@
        ps = init_state();
        ps->ps_owner_uid = pmi->pmi_uid;
 
-       if (pmi->pmi_source)
-               ps->ps_source = strdup(pmi->pmi_source);
-       if (pmi->pmi_filesystemtype)
+       if (pmi->pmi_source) {
+               if ((ps->ps_source = strdup(pmi->pmi_source)) == NULL)
+                       DERR(EX_OSERR, "strdup failed");
+
+               source = ps->ps_source;
+       }
+
+       if (pmi->pmi_filesystemtype) {
+               size_t len;
+
                ps->ps_filesystemtype = strdup(pmi->pmi_filesystemtype);
-       ps->ps_target = strdup(pmi->pmi_target);
+               if (ps->ps_filesystemtype == NULL)
+                       DERR(EX_OSERR, "strdup failed");
+
+               len = sizeof("perfuse|") + strlen(ps->ps_filesystemtype) + 1;
+               if ((fstype = malloc(len)) == NULL)
+                       DERR(EX_OSERR, "malloc failed");
+
+               (void)sprintf(fstype, "perfuse|%s", ps->ps_filesystemtype);
+       } else {
+               if ((fstype = strdup("perfuse")) == NULL)
+                       DERR(EX_OSERR, "strdup failed");
+       }
+
+       if ((ps->ps_target = strdup(pmi->pmi_target)) == NULL)
+               DERR(EX_OSERR, "strdup failed");
+
        ps->ps_mountflags = pmi->pmi_mountflags;
 
        /*
@@ -450,7 +473,7 @@
        if (perfuse_diagflags & PDF_PUFFS)
                puffs_flags |= PUFFS_FLAG_OPDUMP;
 
-       if ((pu = puffs_init(pops, _PATH_PUFFS, name, ps, puffs_flags)) == NULL)
+       if ((pu = puffs_init(pops, source, fstype, ps, puffs_flags)) == NULL)
                DERR(EX_OSERR, "puffs_init failed");
 
        ps->ps_pu = pu;



Home | Main Index | Thread Index | Old Index