free(p->model);
free(p->partflags);
+ free(p->mode);
+ free(p->owner);
+ free(p->group);
+
free(p);
}
prop = ld->properties = xcalloc(1, sizeof(*ld->properties));
while (fgets(buf, sizeof(buf), fp) != NULL) {
+ /* udev based */
if (lookup(buf, "ID_FS_LABEL_ENC", &prop->label))
unhexmangle_string(prop->label);
else if (lookup(buf, "ID_FS_UUID_ENC", &prop->uuid))
else if (lookup(buf, "ID_WWN", &prop->wwn)) ;
else if (lookup(buf, "ID_SCSI_SERIAL", &prop->serial)) ;
else if (lookup(buf, "ID_SERIAL_SHORT", &prop->serial)) ;
+
+ /* lsblk specific */
+ else if (lookup(buf, "MODE", &prop->mode)) ;
+ else if (lookup(buf, "OWNER", &prop->owner)) ;
+ else if (lookup(buf, "GROUP", &prop->group)) ;
+
else
continue;
}
.BR " \-\-sysroot " \fIdirectory\fP
Gather data for a Linux instance other than the instance from which the lsblk
command is issued. The specified directory is the system root of the Linux
-instance to be inspected. This option is designed for the testing purpose.
+instance to be inspected. The real device nodes in the target directory can
+be replaced by text files with udev attributes.
.SH NOTES
For partitions, some information (e.g. queue attributes) is inherited from the
int id, /* column ID (COL_*) */
uint64_t *sortdata) /* returns sort data as number */
{
- struct lsblk_devprop *prop;
+ struct lsblk_devprop *prop = NULL;
char *str = NULL;
switch(id) {
str = xstrdup(dev->filename);
break;
case COL_OWNER:
- {
- struct stat *st = device_get_stat(dev);
- struct passwd *pw = st ? getpwuid(st->st_uid) : NULL;
- if (pw)
- str = xstrdup(pw->pw_name);
+ if (lsblk->sysroot)
+ prop = lsblk_device_get_properties(dev);
+ if (prop && prop->owner) {
+ str = xstrdup(prop->owner);
+ } else {
+ struct stat *st = device_get_stat(dev);
+ struct passwd *pw = st ? getpwuid(st->st_uid) : NULL;
+ if (pw)
+ str = xstrdup(pw->pw_name);
+ }
break;
- }
case COL_GROUP:
- {
- struct stat *st = device_get_stat(dev);
- struct group *gr = st ? getgrgid(st->st_gid) : NULL;
- if (gr)
- str = xstrdup(gr->gr_name);
+ if (lsblk->sysroot)
+ prop = lsblk_device_get_properties(dev);
+ if (prop && prop->group) {
+ str = xstrdup(prop->group);
+ } else {
+ struct stat *st = device_get_stat(dev);
+ struct group *gr = st ? getgrgid(st->st_gid) : NULL;
+ if (gr)
+ str = xstrdup(gr->gr_name);
+ }
break;
- }
case COL_MODE:
- {
- struct stat *st = device_get_stat(dev);
- char md[11] = { '\0' };
+ if (lsblk->sysroot)
+ prop = lsblk_device_get_properties(dev);
+ if (prop && prop->mode) {
+ str = xstrdup(prop->mode);
+ } else {
+ struct stat *st = device_get_stat(dev);
+ char md[11] = { '\0' };
- if (st)
- str = xstrdup(xstrmode(st->st_mode, md));
+ if (st)
+ str = xstrdup(xstrmode(st->st_mode, md));
+ }
break;
- }
case COL_MAJMIN:
if (is_parsable(lsblk))
xasprintf(&str, "%u:%u", dev->maj, dev->min);
extern struct lsblk *lsblk; /* global handler */
struct lsblk_devprop {
+ /* udev / blkid based */
char *fstype; /* detected fs, NULL or "?" if cannot detect */
char *uuid; /* filesystem UUID (or stack uuid) */
char *ptuuid; /* partition table UUID */
char *wwn; /* storage WWN */
char *serial; /* disk serial number */
char *model; /* disk model */
+
+ /* lsblk specific (for --sysroot only) */
+ char *owner; /* user name */
+ char *group; /* group name */
+ char *mode; /* access mode in ls(1)-like notation */
};
/* Device dependence