summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-02 14:53:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:00 -0500
commit3c016355e44afbb10ee02b9ba09e107355b27f7a (patch)
tree9956717de54618fd7c0bf4d7917bfd65ac21a46d /source4/ntvfs/posix
parentf4edfc21e5be94ef982caea1891b2305d7dfba85 (diff)
downloadsamba-3c016355e44afbb10ee02b9ba09e107355b27f7a.tar.gz
samba-3c016355e44afbb10ee02b9ba09e107355b27f7a.tar.bz2
samba-3c016355e44afbb10ee02b9ba09e107355b27f7a.zip
r12019: - let us only reference libblkid stuff in one file
- and make it it bit simpler, by caching the GUID struct instead of the device name - and this also removes all compiler warnings... metze (This used to be commit f4f0d626e00116e85a91962bf8534c1fbb69334c)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_fsinfo.c94
-rw-r--r--source4/ntvfs/posix/vfs_posix.c3
-rw-r--r--source4/ntvfs/posix/vfs_posix.h15
3 files changed, 58 insertions, 54 deletions
diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c
index 3a95ed3ff5..be87599b87 100644
--- a/source4/ntvfs/posix/pvfs_fsinfo.c
+++ b/source4/ntvfs/posix/pvfs_fsinfo.c
@@ -26,19 +26,62 @@
/* We use libblkid out of e2fsprogs to identify UUID of a volume */
#ifdef HAVE_LIBBLKID
-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;
-}
+#include <blkid/blkid.h>
+#endif
+
+static NTSTATUS pvfs_blkid_fs_uuid(struct pvfs_state *pvfs, struct stat *st, struct GUID *uuid)
+{
+#ifdef HAVE_LIBBLKID
+ NTSTATUS status;
+ char *uuid_value = NULL;
+ char *devname = NULL;
+
+ devname = blkid_devno_to_devname(st->st_dev);
+ if (!devname) {
+ return NT_STATUS_DEVICE_CONFIGURATION_ERROR;
+ }
+
+ uuid_value = blkid_get_tag_value(NULL, "UUID", devname);
+ free(devname);
+ if (!uuid_value) {
+ return NT_STATUS_DEVICE_CONFIGURATION_ERROR;
+ }
+
+ status = GUID_from_string(uuid_value, uuid);
+ free(uuid_value);
+ if (!NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_DEVICE_CONFIGURATION_ERROR;
+ }
+ return NT_STATUS_OK;
+#else
+ ZERO_STRUCTP(uuid);
+ return NT_STATUS_OK;
#endif
+}
+
+static NTSTATUS pvfs_cache_base_fs_uuid(struct pvfs_state *pvfs, struct stat *st)
+{
+ NTSTATUS status;
+ struct GUID uuid;
+
+ if (pvfs->base_fs_uuid) return NT_STATUS_OK;
+
+ status = pvfs_blkid_fs_uuid(pvfs, st, &uuid);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ pvfs->base_fs_uuid = talloc(pvfs, struct GUID);
+ NT_STATUS_HAVE_NO_MEMORY(pvfs->base_fs_uuid);
+ *pvfs->base_fs_uuid = uuid;
+
+ return NT_STATUS_OK;
+}
/*
return filesystem space info
*/
NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs,
struct smbsrv_request *req, union smb_fsinfo *fs)
{
+ NTSTATUS status;
struct pvfs_state *pvfs = ntvfs->private_data;
uint64_t blocks_free, blocks_total;
uint_t bpunit;
@@ -145,38 +188,15 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OK;
case RAW_QFS_OBJECTID_INFORMATION:
- {
-#ifdef HAVE_LIBBLKID
- NTSTATUS status;
- const char *uuid_value;
-#endif
- ZERO_STRUCT(fs->objectid_information.out);
-#ifdef HAVE_LIBBLKID
- if (!pvfs->blkid_cache) {
- pvfs->blkid_cache = talloc(ntvfs, blkid_cache_wrap_t);
-
- if (!pvfs->blkid_cache) {
- return NT_STATUS_NO_MEMORY;
- }
-
- 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
+ ZERO_STRUCT(fs->objectid_information.out.guid);
+ ZERO_STRUCT(fs->objectid_information.out.unknown);
+
+ status = pvfs_cache_base_fs_uuid(pvfs, &st);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ fs->objectid_information.out.guid = *pvfs->base_fs_uuid;
return NT_STATUS_OK;
- }
+
default:
break;
}
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index a4b15e3c57..bedc81389c 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -95,9 +95,6 @@ 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
/* check if the system really supports xattrs */
if (pvfs->flags & PVFS_FLAG_XATTR_ENABLE) {
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index f18864197d..9eec368157 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -26,21 +26,12 @@
#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 {
struct smbsrv_tcon *tcon;
const char *base_directory;
+ struct GUID *base_fs_uuid;
const char *share_name;
uint_t flags;
@@ -83,10 +74,6 @@ 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 */