summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_fsinfo.c54
-rw-r--r--source4/ntvfs/posix/vfs_posix.c3
-rw-r--r--source4/ntvfs/posix/vfs_posix.h14
3 files changed, 52 insertions, 19 deletions
diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c
index 6046ecb6f8..3a95ed3ff5 100644
--- a/source4/ntvfs/posix/pvfs_fsinfo.c
+++ b/source4/ntvfs/posix/pvfs_fsinfo.c
@@ -26,9 +26,13 @@
/* We use libblkid out of e2fsprogs to identify UUID of a volume */
#ifdef HAVE_LIBBLKID
-#include <blkid/blkid.h>
+static int blkid_cache_destructor(void * cache_wrap) {
+ blkid_cache_wrap_t * cache = (blkid_cache_wrap_t *)cache_wrap;
+ blkid_put_cache(cache->cache);
+ if(cache->devname) free((void *)cache->devname);
+ return 0;
+}
#endif
-
/*
return filesystem space info
*/
@@ -141,28 +145,40 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OK;
case RAW_QFS_OBJECTID_INFORMATION:
- {
+ {
#ifdef HAVE_LIBBLKID
- NTSTATUS status;
- blkid_cache blk_cache = NULL;
- const char *uuid_value;
- const char *blkid_devname;
-
+ NTSTATUS status;
+ const char *uuid_value;
#endif
- ZERO_STRUCT(fs->objectid_information.out);
+ ZERO_STRUCT(fs->objectid_information.out);
#ifdef HAVE_LIBBLKID
- blkid_devname = blkid_devno_to_devname(st.st_dev);
- if (!blk_cache && blkid_get_cache(&blk_cache,NULL) < 0 ) {
- return NT_STATUS_DEVICE_CONFIGURATION_ERROR;
+ if (!pvfs->blkid_cache) {
+ pvfs->blkid_cache = talloc(ntvfs, blkid_cache_wrap_t);
+
+ if (!pvfs->blkid_cache) {
+ return NT_STATUS_NO_MEMORY;
}
- if ((uuid_value = blkid_get_tag_value(blk_cache, "UUID", blkid_devname))) {
- GUID_from_string(uuid_value, &fs->objectid_information.out.guid);
- free(uuid_value);
- }
-#endif
- return NT_STATUS_OK;
+
+ pvfs->blkid_cache->cache = NULL;
+ pvfs->blkid_cache->devname = blkid_devno_to_devname(st.st_dev);
+
+ talloc_set_destructor(pvfs->blkid_cache, blkid_cache_destructor);
+
+ if (blkid_get_cache(&pvfs->blkid_cache->cache,NULL) < 0 ) {
+ return NT_STATUS_DEVICE_CONFIGURATION_ERROR;
+ }
+ }
+
+ if ((uuid_value = blkid_get_tag_value(pvfs->blkid_cache->cache,
+ "UUID", pvfs->blkid_cache->devname))) {
+ GUID_from_string(uuid_value, &fs->objectid_information.out.guid);
+ free((void*)uuid_value);
}
+#endif
+ return NT_STATUS_OK;
+ }
+ default:
+ break;
}
-
return NT_STATUS_INVALID_LEVEL;
}
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index ec8db07d01..1d3979aabf 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -88,6 +88,9 @@ static void pvfs_setup_options(struct pvfs_state *pvfs)
pvfs->sid_cache.creator_owner = dom_sid_parse_talloc(pvfs, SID_CREATOR_OWNER);
pvfs->sid_cache.creator_group = dom_sid_parse_talloc(pvfs, SID_CREATOR_GROUP);
+#ifdef HAVE_BLKID
+ pvfs->blkid_cache = NULL;
+#endif
}
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index f779936bf9..a55674d69a 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -26,6 +26,16 @@
#include "system/filesys.h"
#include "smb_server/smb_server.h"
+/* We use libblkid out of e2fsprogs to identify UUID of a volume */
+#ifdef HAVE_LIBBLKID
+#include <blkid/blkid.h>
+
+typedef struct {
+ blkid_cache cache;
+ const char *devname;
+} blkid_cache_wrap_t;
+#endif
+
/* this is the private structure for the posix vfs backend. It is used
to hold per-connection (per tree connect) state information */
struct pvfs_state {
@@ -67,6 +77,10 @@ struct pvfs_state {
const struct dom_sid *creator_owner;
const struct dom_sid *creator_group;
} sid_cache;
+
+#ifdef HAVE_LIBBLKID
+ blkid_cache_wrap_t *blkid_cache;
+#endif
};
/* this is the basic information needed about a file from the filesystem */