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_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)
|
||||
int sigar_get_iftype(const char *name, int *type, int *inst);
|
||||
#endif
|
||||
|
|
|
@ -1507,8 +1507,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
|||
|
||||
#define LSPV_CMD "/usr/sbin/lspv"
|
||||
|
||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
long addr;
|
||||
|
@ -1576,7 +1574,7 @@ static int create_diskmap_v4(sigar_t *sigar)
|
|||
aix_diskio_t *diskio = malloc(sizeof(*diskio));
|
||||
diskio->name = strdup(disk);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1642,7 +1640,7 @@ static int create_diskmap_v5(sigar_t *sigar)
|
|||
aix_diskio_t *diskio = malloc(sizeof(*diskio));
|
||||
diskio->name = strdup(disk[i].name);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1811,7 +1809,7 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
|||
status = stat(dirname, &sb);
|
||||
if (status == 0) {
|
||||
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) {
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
|
|
@ -560,8 +560,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
|||
#define SIGAR_FS_BLOCKS_TO_BYTES(buf, f) \
|
||||
(((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)
|
||||
{
|
||||
sigar_file_system_list_t fslist;
|
||||
|
@ -586,7 +584,7 @@ static int create_fsdev_cache(sigar_t *sigar)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +626,7 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
|||
char *devname;
|
||||
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) {
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
|
|
@ -1174,8 +1174,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
|||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
||||
|
||||
#define FSDEV_IS_DEV(dev) strnEQ(dev, "/dev/", 5)
|
||||
|
||||
#define ST_MAJOR(sb) major((sb).st_rdev)
|
||||
|
@ -1204,7 +1202,7 @@ static iodev_t *get_fsdev(sigar_t *sigar,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
id = FSDEV_ID(sb);
|
||||
id = SIGAR_FSDEV_ID(sb);
|
||||
|
||||
if (!sigar->fsdev) {
|
||||
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 */
|
||||
}
|
||||
|
||||
ent = sigar_cache_get(sigar->fsdev, FSDEV_ID(sb));
|
||||
ent = sigar_cache_get(sigar->fsdev, SIGAR_FSDEV_ID(sb));
|
||||
if (ent->value) {
|
||||
continue; /* already cached */
|
||||
}
|
||||
|
|
|
@ -1457,8 +1457,6 @@ static fsdev_path_t *get_fsdev_paths(sigar_t *sigar,
|
|||
return mapping;
|
||||
}
|
||||
|
||||
#define FSDEV_ID(sb) (sb.st_ino + sb.st_dev)
|
||||
|
||||
static int create_fsdev_cache(sigar_t *sigar)
|
||||
{
|
||||
fsdev_path_t *paths, *mapping;
|
||||
|
@ -1530,7 +1528,7 @@ static int create_fsdev_cache(sigar_t *sigar)
|
|||
SIGAR_SSTRCPY(fs_kstat->module, paths->name);
|
||||
fs_kstat->instance = paths->instance;
|
||||
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;
|
||||
|
||||
if (debug) {
|
||||
|
@ -1650,7 +1648,7 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
|||
if (stat(dirname, &sb) < 0) {
|
||||
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) {
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue