share FSDEV_ID macro
This commit is contained in:
parent
8fb0941eca
commit
98157a49ce
|
@ -314,6 +314,9 @@ int sigar_group_name_get(sigar_t *sigar, int gid, char *buf, int buflen);
|
||||||
fsusage->disk_read_bytes = fsusage->disk_write_bytes = \
|
fsusage->disk_read_bytes = fsusage->disk_write_bytes = \
|
||||||
fsusage->disk_queue = fsusage->disk_time = SIGAR_FIELD_NOTIMPL;
|
fsusage->disk_queue = fsusage->disk_time = SIGAR_FIELD_NOTIMPL;
|
||||||
|
|
||||||
|
/* key used for filesystem (/) -> device (/dev/hda1) mapping */
|
||||||
|
#define SIGAR_FSDEV_ID(sb) ((sb).st_ino + (sb).st_dev)
|
||||||
|
|
||||||
#if defined(WIN32) || defined(NETWARE)
|
#if defined(WIN32) || defined(NETWARE)
|
||||||
int sigar_get_iftype(const char *name, int *type, int *inst);
|
int sigar_get_iftype(const char *name, int *type, int *inst);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1507,8 +1507,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||||
|
|
||||||
#define LSPV_CMD "/usr/sbin/lspv"
|
#define LSPV_CMD "/usr/sbin/lspv"
|
||||||
|
|
||||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
long addr;
|
long addr;
|
||||||
|
@ -1576,7 +1574,7 @@ static int create_diskmap_v4(sigar_t *sigar)
|
||||||
aix_diskio_t *diskio = malloc(sizeof(*diskio));
|
aix_diskio_t *diskio = malloc(sizeof(*diskio));
|
||||||
diskio->name = strdup(disk);
|
diskio->name = strdup(disk);
|
||||||
diskio->addr = -1;
|
diskio->addr = -1;
|
||||||
ent = sigar_cache_get(sigar->diskmap, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->diskmap, SIGAR_FSDEV_ID(sb));
|
||||||
ent->value = diskio;
|
ent->value = diskio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1642,7 +1640,7 @@ static int create_diskmap_v5(sigar_t *sigar)
|
||||||
aix_diskio_t *diskio = malloc(sizeof(*diskio));
|
aix_diskio_t *diskio = malloc(sizeof(*diskio));
|
||||||
diskio->name = strdup(disk[i].name);
|
diskio->name = strdup(disk[i].name);
|
||||||
diskio->addr = -1;
|
diskio->addr = -1;
|
||||||
ent = sigar_cache_get(sigar->diskmap, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->diskmap, SIGAR_FSDEV_ID(sb));
|
||||||
ent->value = diskio;
|
ent->value = diskio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1811,7 +1809,7 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
||||||
status = stat(dirname, &sb);
|
status = stat(dirname, &sb);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
sigar_cache_entry_t *ent =
|
sigar_cache_entry_t *ent =
|
||||||
sigar_cache_get(sigar->diskmap, FSDEV_ID(sb));
|
sigar_cache_get(sigar->diskmap, SIGAR_FSDEV_ID(sb));
|
||||||
if (!ent->value) {
|
if (!ent->value) {
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,8 +560,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||||
#define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \
|
#define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \
|
||||||
(((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1)
|
(((sigar_uint64_t)buf.f * (buf.f_bsize / 512)) >> 1)
|
||||||
|
|
||||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
|
||||||
|
|
||||||
static int create_fsdev_cache(sigar_t *sigar)
|
static int create_fsdev_cache(sigar_t *sigar)
|
||||||
{
|
{
|
||||||
sigar_file_system_list_t fslist;
|
sigar_file_system_list_t fslist;
|
||||||
|
@ -586,7 +584,7 @@ static int create_fsdev_cache(sigar_t *sigar)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent = sigar_cache_get(sigar->fsdev, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->fsdev, SIGAR_FSDEV_ID(sb));
|
||||||
ent->value = strdup(fsp->dev_name);
|
ent->value = strdup(fsp->dev_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,7 +626,7 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
||||||
char *devname;
|
char *devname;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
ent = sigar_cache_get(sigar->fsdev, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->fsdev, SIGAR_FSDEV_ID(sb));
|
||||||
if (ent->value == NULL) {
|
if (ent->value == NULL) {
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1174,8 +1174,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
|
||||||
|
|
||||||
#define FSDEV_IS_DEV(dev) strnEQ(dev, "/dev/", 5)
|
#define FSDEV_IS_DEV(dev) strnEQ(dev, "/dev/", 5)
|
||||||
|
|
||||||
#define ST_MAJOR(sb) major((sb).st_rdev)
|
#define ST_MAJOR(sb) major((sb).st_rdev)
|
||||||
|
@ -1204,7 +1202,7 @@ static iodev_t *get_fsdev(sigar_t *sigar,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
id = FSDEV_ID(sb);
|
id = SIGAR_FSDEV_ID(sb);
|
||||||
|
|
||||||
if (!sigar->fsdev) {
|
if (!sigar->fsdev) {
|
||||||
sigar->fsdev = sigar_cache_new(15);
|
sigar->fsdev = sigar_cache_new(15);
|
||||||
|
@ -1241,7 +1239,7 @@ static iodev_t *get_fsdev(sigar_t *sigar,
|
||||||
return NULL; /* cant cache w/o inode */
|
return NULL; /* cant cache w/o inode */
|
||||||
}
|
}
|
||||||
|
|
||||||
ent = sigar_cache_get(sigar->fsdev, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->fsdev, SIGAR_FSDEV_ID(sb));
|
||||||
if (ent->value) {
|
if (ent->value) {
|
||||||
continue; /* already cached */
|
continue; /* already cached */
|
||||||
}
|
}
|
||||||
|
|
|
@ -1457,8 +1457,6 @@ static fsdev_path_t *get_fsdev_paths(sigar_t *sigar,
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
|
||||||
|
|
||||||
static int create_fsdev_cache(sigar_t *sigar)
|
static int create_fsdev_cache(sigar_t *sigar)
|
||||||
{
|
{
|
||||||
fsdev_path_t *paths, *mapping;
|
fsdev_path_t *paths, *mapping;
|
||||||
|
@ -1530,7 +1528,7 @@ static int create_fsdev_cache(sigar_t *sigar)
|
||||||
SIGAR_SSTRCPY(fs_kstat->module, paths->name);
|
SIGAR_SSTRCPY(fs_kstat->module, paths->name);
|
||||||
fs_kstat->instance = paths->instance;
|
fs_kstat->instance = paths->instance;
|
||||||
fs_kstat->partition = partition;
|
fs_kstat->partition = partition;
|
||||||
ent = sigar_cache_get(sigar->fsdev, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->fsdev, SIGAR_FSDEV_ID(sb));
|
||||||
ent->value = fs_kstat;
|
ent->value = fs_kstat;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -1650,7 +1648,7 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
||||||
if (stat(dirname, &sb) < 0) {
|
if (stat(dirname, &sb) < 0) {
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
ent = sigar_cache_get(sigar->fsdev, FSDEV_ID(sb));
|
ent = sigar_cache_get(sigar->fsdev, SIGAR_FSDEV_ID(sb));
|
||||||
if (ent->value == NULL) {
|
if (ent->value == NULL) {
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue