1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-25 06:04:04 +03:00

r6599: Fix formating using 'linux' C style

Fix memory handling for blkid caches which need to be cleared when session is
done.
(This used to be commit c623cc60541f747f0a801eb77d97bb0a3bb6956f)
This commit is contained in:
Alexander Bokovoy 2005-05-03 13:02:14 +00:00 committed by Gerald (Jerry) Carter
parent f37f8a49a7
commit 46727924a0
4 changed files with 216 additions and 170 deletions

View File

@ -1679,7 +1679,6 @@ typedef struct {
} fsinfo_level_t;
fsinfo_level_t fsinfo_levels[] = {
{"generic", RAW_QFS_GENERIC},
{"dskattr", RAW_QFS_DSKATTR},
{"allocation", RAW_QFS_ALLOCATION},
{"volume", RAW_QFS_VOLUME},
@ -1701,7 +1700,6 @@ fsinfo_level_t fsinfo_levels[] = {
static int cmd_fsinfo(const char **cmd_ptr)
{
pstring level_name;
fstring buf;
int ret = 0;
union smb_fsinfo fsinfo;
@ -1740,94 +1738,109 @@ static int cmd_fsinfo(const char **cmd_ptr)
d_printf("fsinfo-level-%s:\n", fsinfo_level->level_name);
switch(fsinfo.generic.level) {
case RAW_QFS_GENERIC:
d_printf("\tblock_size: %lu\n", fsinfo.generic.out.block_size);
d_printf("\tblocks_total: %llu\n", fsinfo.generic.out.blocks_total);
d_printf("\tblocks_free: %llu\n", fsinfo.generic.out.blocks_free);
d_printf("\tfs_id: %lu\n", fsinfo.generic.out.fs_id);
d_printf("\tcreate_time: %s\n", nt_time_string(mem_ctx,fsinfo.generic.out.create_time));
d_printf("\tserial_number: %lu\n", fsinfo.generic.out.serial_number);
d_printf("\tfs_attr: %lx\n", fsinfo.generic.out.fs_attr);
d_printf("\tmax_file_component_length: %lu\n", fsinfo.generic.out.max_file_component_length);
d_printf("\tdevice_type: %lu\n", fsinfo.generic.out.device_type);
d_printf("\tdevice_characteristics: %lx\n", fsinfo.generic.out.device_characteristics);
d_printf("\tquota_soft: %llu\n", fsinfo.generic.out.quota_soft);
d_printf("\tquota_hard: %llu\n", fsinfo.generic.out.quota_hard);
d_printf("\tquota_flags: %llx\n", fsinfo.generic.out.quota_flags);
d_printf("\tGUID: %s\n", GUID_string(mem_ctx,&fsinfo.generic.out.guid));
d_printf("\tvolume_name: %s\n", fsinfo.generic.out.volume_name);
d_printf("\tfs_type: %s\n", fsinfo.generic.out.fs_type);
break;
case RAW_QFS_DSKATTR:
d_printf("\tunits_total: %hu\n", fsinfo.dskattr.out.units_total);
d_printf("\tblocks_per_unit: %hu\n", fsinfo.dskattr.out.blocks_per_unit);
d_printf("\tblocks_size: %hu\n", fsinfo.dskattr.out.block_size);
d_printf("\tunits_free: %hu\n", fsinfo.dskattr.out.units_free);
d_printf("\tunits_total: %hu\n",
(unsigned short) fsinfo.dskattr.out.units_total);
d_printf("\tblocks_per_unit: %hu\n",
(unsigned short) fsinfo.dskattr.out.blocks_per_unit);
d_printf("\tblocks_size: %hu\n",
(unsigned short) fsinfo.dskattr.out.block_size);
d_printf("\tunits_free: %hu\n",
(unsigned short) fsinfo.dskattr.out.units_free);
break;
case RAW_QFS_ALLOCATION:
d_printf("\tfs_id: %lu\n", fsinfo.allocation.out.fs_id);
d_printf("\tsectors_per_unit: %lu\n", fsinfo.allocation.out.sectors_per_unit);
d_printf("\ttotal_alloc_units: %lu\n", fsinfo.allocation.out.total_alloc_units);
d_printf("\tavail_alloc_units: %lu\n", fsinfo.allocation.out.avail_alloc_units);
d_printf("\tbytes_per_sector: %hu\n", fsinfo.allocation.out.bytes_per_sector);
d_printf("\tfs_id: %lu\n",
(unsigned long) fsinfo.allocation.out.fs_id);
d_printf("\tsectors_per_unit: %lu\n",
(unsigned long) fsinfo.allocation.out.sectors_per_unit);
d_printf("\ttotal_alloc_units: %lu\n",
(unsigned long) fsinfo.allocation.out.total_alloc_units);
d_printf("\tavail_alloc_units: %lu\n",
(unsigned long) fsinfo.allocation.out.avail_alloc_units);
d_printf("\tbytes_per_sector: %hu\n",
(unsigned short) fsinfo.allocation.out.bytes_per_sector);
break;
case RAW_QFS_VOLUME:
d_printf("\tserial_number: %lu\n", fsinfo.volume.out.serial_number);
d_printf("\tserial_number: %lu\n",
(unsigned long) fsinfo.volume.out.serial_number);
d_printf("\tvolume_name: %s\n", fsinfo.volume.out.volume_name.s);
break;
case RAW_QFS_VOLUME_INFO:
case RAW_QFS_VOLUME_INFORMATION:
d_printf("\tcreate_time: %s\n", nt_time_string(mem_ctx,fsinfo.volume_info.out.create_time));
d_printf("\tserial_number: %lu\n", fsinfo.volume_info.out.serial_number);
d_printf("\tcreate_time: %s\n",
nt_time_string(mem_ctx,fsinfo.volume_info.out.create_time));
d_printf("\tserial_number: %lu\n",
(unsigned long) fsinfo.volume_info.out.serial_number);
d_printf("\tvolume_name: %s\n", fsinfo.volume_info.out.volume_name.s);
break;
case RAW_QFS_SIZE_INFO:
case RAW_QFS_SIZE_INFORMATION:
d_printf("\ttotal_alloc_units: %llu\n", fsinfo.size_info.out.total_alloc_units);
d_printf("\tavail_alloc_units: %llu\n", fsinfo.size_info.out.avail_alloc_units);
d_printf("\tsectors_per_unit: %lu\n", fsinfo.size_info.out.sectors_per_unit);
d_printf("\tbytes_per_sector: %lu\n", fsinfo.size_info.out.bytes_per_sector);
d_printf("\ttotal_alloc_units: %llu\n",
(unsigned long long) fsinfo.size_info.out.total_alloc_units);
d_printf("\tavail_alloc_units: %llu\n",
(unsigned long long) fsinfo.size_info.out.avail_alloc_units);
d_printf("\tsectors_per_unit: %lu\n",
(unsigned long) fsinfo.size_info.out.sectors_per_unit);
d_printf("\tbytes_per_sector: %lu\n",
(unsigned long) fsinfo.size_info.out.bytes_per_sector);
break;
case RAW_QFS_DEVICE_INFO:
case RAW_QFS_DEVICE_INFORMATION:
d_printf("\tdevice_type: %lu\n", fsinfo.device_info.out.device_type);
d_printf("\tcharacteristics: %lx\n", fsinfo.device_info.out.characteristics);
d_printf("\tdevice_type: %lu\n",
(unsigned long) fsinfo.device_info.out.device_type);
d_printf("\tcharacteristics: 0x%lx\n",
(unsigned long) fsinfo.device_info.out.characteristics);
break;
case RAW_QFS_ATTRIBUTE_INFORMATION:
case RAW_QFS_ATTRIBUTE_INFO:
d_printf("\tfs_attr: %lx\n", fsinfo.attribute_info.out.fs_attr);
d_printf("\tmax_file_component_length: %lu\n", fsinfo.attribute_info.out.max_file_component_length);
d_printf("\tfs_attr: 0x%lx\n",
(unsigned long) fsinfo.attribute_info.out.fs_attr);
d_printf("\tmax_file_component_length: %lu\n",
(unsigned long) fsinfo.attribute_info.out.max_file_component_length);
d_printf("\tfs_type: %s\n", fsinfo.attribute_info.out.fs_type.s);
break;
case RAW_QFS_UNIX_INFO:
d_printf("\tmajor_version: %hu\n", fsinfo.unix_info.out.major_version);
d_printf("\tminor_version: %hu\n", fsinfo.unix_info.out.minor_version);
d_printf("\tcapability: %llx\n", fsinfo.unix_info.out.capability);
d_printf("\tmajor_version: %hu\n",
(unsigned short) fsinfo.unix_info.out.major_version);
d_printf("\tminor_version: %hu\n",
(unsigned short) fsinfo.unix_info.out.minor_version);
d_printf("\tcapability: 0x%llx\n",
(unsigned long long) fsinfo.unix_info.out.capability);
break;
case RAW_QFS_QUOTA_INFORMATION:
d_printf("\tunknown[3]: [%llu,%llu,%llu]\n", fsinfo.quota_information.out.unknown[0],
fsinfo.quota_information.out.unknown[1],
fsinfo.quota_information.out.unknown[2]);
d_printf("\tquota_soft: %llu\n", fsinfo.quota_information.out.quota_soft);
d_printf("\tquota_hard: %llu\n", fsinfo.quota_information.out.quota_hard);
d_printf("\tquota_flags: %llx\n", fsinfo.quota_information.out.quota_flags);
d_printf("\tunknown[3]: [%llu,%llu,%llu]\n",
(unsigned long long) fsinfo.quota_information.out.unknown[0],
(unsigned long long) fsinfo.quota_information.out.unknown[1],
(unsigned long long) fsinfo.quota_information.out.unknown[2]);
d_printf("\tquota_soft: %llu\n",
(unsigned long long) fsinfo.quota_information.out.quota_soft);
d_printf("\tquota_hard: %llu\n",
(unsigned long long) fsinfo.quota_information.out.quota_hard);
d_printf("\tquota_flags: 0x%llx\n",
(unsigned long long) fsinfo.quota_information.out.quota_flags);
break;
case RAW_QFS_FULL_SIZE_INFORMATION:
d_printf("\ttotal_alloc_units: %llu\n", fsinfo.full_size_information.out.total_alloc_units);
d_printf("\tcall_avail_alloc_units: %llu\n", fsinfo.full_size_information.out.call_avail_alloc_units);
d_printf("\tactual_avail_alloc_units: %llu\n", fsinfo.full_size_information.out.actual_avail_alloc_units);
d_printf("\tsectors_per_unit: %lu\n", fsinfo.full_size_information.out.sectors_per_unit);
d_printf("\tbytes_per_sector: %lu\n", fsinfo.full_size_information.out.bytes_per_sector);
d_printf("\ttotal_alloc_units: %llu\n",
(unsigned long long) fsinfo.full_size_information.out.total_alloc_units);
d_printf("\tcall_avail_alloc_units: %llu\n",
(unsigned long long) fsinfo.full_size_information.out.call_avail_alloc_units);
d_printf("\tactual_avail_alloc_units: %llu\n",
(unsigned long long) fsinfo.full_size_information.out.actual_avail_alloc_units);
d_printf("\tsectors_per_unit: %lu\n",
(unsigned long) fsinfo.full_size_information.out.sectors_per_unit);
d_printf("\tbytes_per_sector: %lu\n",
(unsigned long) fsinfo.full_size_information.out.bytes_per_sector);
break;
case RAW_QFS_OBJECTID_INFORMATION:
d_printf("\tGUID: %s\n", GUID_string(mem_ctx,&fsinfo.objectid_information.out.guid));
d_printf("\tGUID: %s\n",
GUID_string(mem_ctx,&fsinfo.objectid_information.out.guid));
d_printf("\tunknown[6]: [%llu,%llu,%llu,%llu,%llu,%llu]\n",
fsinfo.objectid_information.out.unknown[0],
fsinfo.objectid_information.out.unknown[2],
fsinfo.objectid_information.out.unknown[3],
fsinfo.objectid_information.out.unknown[4],
fsinfo.objectid_information.out.unknown[5],
fsinfo.objectid_information.out.unknown[6] );
(unsigned long long) fsinfo.objectid_information.out.unknown[0],
(unsigned long long) fsinfo.objectid_information.out.unknown[2],
(unsigned long long) fsinfo.objectid_information.out.unknown[3],
(unsigned long long) fsinfo.objectid_information.out.unknown[4],
(unsigned long long) fsinfo.objectid_information.out.unknown[5],
(unsigned long long) fsinfo.objectid_information.out.unknown[6] );
break;
}

View File

@ -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
*/
@ -144,25 +148,37 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs,
{
#ifdef HAVE_LIBBLKID
NTSTATUS status;
blkid_cache blk_cache = NULL;
const char *uuid_value;
const char *blkid_devname;
#endif
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 ) {
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(blk_cache, "UUID", blkid_devname))) {
}
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(uuid_value);
free((void*)uuid_value);
}
#endif
return NT_STATUS_OK;
}
default:
break;
}
return NT_STATUS_INVALID_LEVEL;
}

View File

@ -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
}

View File

@ -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 */