]> granicus.if.org Git - zfs/commitdiff
Merge commit 'refs/top-bases/gcc-shadow' into gcc-shadow
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 15 Jan 2009 22:05:38 +0000 (14:05 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 15 Jan 2009 22:05:38 +0000 (14:05 -0800)
1  2 
lib/libzfs/libzfs_dataset.c
lib/libzfs/libzfs_mount.c
lib/libzfs/libzfs_util.c
module/zfs/dnode.c
module/zfs/txg.c

index b66b24ebc1d31335fb6bda31f6b292fc61abd0ae,a381a0e63a9c941848c9c71396b0d600c46e8788..509b1732f4e9c5ec2e08b1da8d59f4f3327163a7
@@@ -527,15 -583,127 +583,126 @@@ zfs_close(zfs_handle_t *zhp
        free(zhp);
  }
  
+ typedef struct mnttab_node {
+       struct mnttab mtn_mt;
+       avl_node_t mtn_node;
+ } mnttab_node_t;
+ static int
+ libzfs_mnttab_cache_compare(const void *arg1, const void *arg2)
+ {
+       const mnttab_node_t *mtn1 = arg1;
+       const mnttab_node_t *mtn2 = arg2;
+       int rv;
+       rv = strcmp(mtn1->mtn_mt.mnt_special, mtn2->mtn_mt.mnt_special);
+       if (rv == 0)
+               return (0);
+       return (rv > 0 ? 1 : -1);
+ }
+ void
+ libzfs_mnttab_init(libzfs_handle_t *hdl)
+ {
+       struct mnttab entry;
+       assert(avl_numnodes(&hdl->libzfs_mnttab_cache) == 0);
+       avl_create(&hdl->libzfs_mnttab_cache, libzfs_mnttab_cache_compare,
+           sizeof (mnttab_node_t), offsetof(mnttab_node_t, mtn_node));
+       rewind(hdl->libzfs_mnttab);
+       while (getmntent(hdl->libzfs_mnttab, &entry) == 0) {
+               mnttab_node_t *mtn;
+               if (strcmp(entry.mnt_fstype, MNTTYPE_ZFS) != 0)
+                       continue;
+               mtn = zfs_alloc(hdl, sizeof (mnttab_node_t));
+               mtn->mtn_mt.mnt_special = zfs_strdup(hdl, entry.mnt_special);
+               mtn->mtn_mt.mnt_mountp = zfs_strdup(hdl, entry.mnt_mountp);
+               mtn->mtn_mt.mnt_fstype = zfs_strdup(hdl, entry.mnt_fstype);
+               mtn->mtn_mt.mnt_mntopts = zfs_strdup(hdl, entry.mnt_mntopts);
+               avl_add(&hdl->libzfs_mnttab_cache, mtn);
+       }
+ }
+ void
+ libzfs_mnttab_fini(libzfs_handle_t *hdl)
+ {
+       void *cookie = NULL;
+       mnttab_node_t *mtn;
+       while (mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) {
+               free(mtn->mtn_mt.mnt_special);
+               free(mtn->mtn_mt.mnt_mountp);
+               free(mtn->mtn_mt.mnt_fstype);
+               free(mtn->mtn_mt.mnt_mntopts);
+               free(mtn);
+       }
+       avl_destroy(&hdl->libzfs_mnttab_cache);
+ }
+ int
+ libzfs_mnttab_find(libzfs_handle_t *hdl, const char *fsname,
+     struct mnttab *entry)
+ {
+       mnttab_node_t find;
+       mnttab_node_t *mtn;
+       if (avl_numnodes(&hdl->libzfs_mnttab_cache) == 0)
+               libzfs_mnttab_init(hdl);
+       find.mtn_mt.mnt_special = (char *)fsname;
+       mtn = avl_find(&hdl->libzfs_mnttab_cache, &find, NULL);
+       if (mtn) {
+               *entry = mtn->mtn_mt;
+               return (0);
+       }
+       return (ENOENT);
+ }
+ void
+ libzfs_mnttab_add(libzfs_handle_t *hdl, const char *special,
+     const char *mountp, const char *mntopts)
+ {
+       mnttab_node_t *mtn;
+       if (avl_numnodes(&hdl->libzfs_mnttab_cache) == 0)
+               return;
+       mtn = zfs_alloc(hdl, sizeof (mnttab_node_t));
+       mtn->mtn_mt.mnt_special = zfs_strdup(hdl, special);
+       mtn->mtn_mt.mnt_mountp = zfs_strdup(hdl, mountp);
+       mtn->mtn_mt.mnt_fstype = zfs_strdup(hdl, MNTTYPE_ZFS);
+       mtn->mtn_mt.mnt_mntopts = zfs_strdup(hdl, mntopts);
+       avl_add(&hdl->libzfs_mnttab_cache, mtn);
+ }
+ void
+ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname)
+ {
+       mnttab_node_t find;
+       mnttab_node_t *ret;
+       find.mtn_mt.mnt_special = (char *)fsname;
+       if (ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) {
+               avl_remove(&hdl->libzfs_mnttab_cache, ret);
+               free(ret->mtn_mt.mnt_special);
+               free(ret->mtn_mt.mnt_mountp);
+               free(ret->mtn_mt.mnt_fstype);
+               free(ret->mtn_mt.mnt_mntopts);
+               free(ret);
+       }
+ }
  int
 -zfs_spa_version(zfs_handle_t *zhp, int *spa_version)
 +zfs_spa_version(zfs_handle_t *zhp, int *version)
  {
 -      zpool_handle_t *zpool_handle = zhp->zpool_hdl;
 +      zpool_handle_t *handle = zhp->zpool_hdl;
  
 -      if (zpool_handle == NULL)
 +      if (handle == NULL)
                return (-1);
  
 -      *spa_version = zpool_get_prop_int(zpool_handle,
 -          ZPOOL_PROP_VERSION, NULL);
 +      *version = zpool_get_prop_int(handle, ZPOOL_PROP_VERSION, NULL);
        return (0);
  }
  
Simple merge
Simple merge
Simple merge
Simple merge