mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
vol_id: add --skip-raid and --probe-all option
This commit is contained in:
parent
f566b05b57
commit
7d5ccc0810
@ -13,7 +13,7 @@ INSTALL_DATA = ${INSTALL} -m 644
|
|||||||
INSTALL_LIB = ${INSTALL} -m 755
|
INSTALL_LIB = ${INSTALL} -m 755
|
||||||
|
|
||||||
SHLIB_CUR = 0
|
SHLIB_CUR = 0
|
||||||
SHLIB_REV = 66
|
SHLIB_REV = 67
|
||||||
SHLIB_AGE = 0
|
SHLIB_AGE = 0
|
||||||
SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
|
SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
volume_id_probe_raid;
|
volume_id_probe_raid;
|
||||||
volume_id_close;
|
volume_id_close;
|
||||||
|
|
||||||
|
volume_id_probe_linux_swap;
|
||||||
|
volume_id_probe_luks;
|
||||||
volume_id_probe_cramfs;
|
volume_id_probe_cramfs;
|
||||||
volume_id_probe_ext;
|
volume_id_probe_ext;
|
||||||
volume_id_probe_vfat;
|
volume_id_probe_vfat;
|
||||||
@ -41,6 +43,8 @@
|
|||||||
volume_id_probe_promise_fasttrack_raid;
|
volume_id_probe_promise_fasttrack_raid;
|
||||||
volume_id_probe_silicon_medley_raid;
|
volume_id_probe_silicon_medley_raid;
|
||||||
volume_id_probe_via_raid;
|
volume_id_probe_via_raid;
|
||||||
|
volume_id_probe_adaptec_raid;
|
||||||
|
volume_id_probe_jmicron_raid;
|
||||||
local:
|
local:
|
||||||
*;
|
*;
|
||||||
};
|
};
|
||||||
|
@ -102,21 +102,21 @@ int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size
|
|||||||
info("probing at offset 0x%llx, size 0x%llx",
|
info("probing at offset 0x%llx, size 0x%llx",
|
||||||
(unsigned long long) off, (unsigned long long) size);
|
(unsigned long long) off, (unsigned long long) size);
|
||||||
|
|
||||||
if (volume_id_probe_luks(id, off) == 0)
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
if (volume_id_probe_vfat(id, off) == 0)
|
if (volume_id_probe_vfat(id, off) == 0)
|
||||||
goto found;
|
goto found;
|
||||||
|
|
||||||
if (volume_id_probe_xfs(id, off) == 0)
|
|
||||||
goto found;
|
|
||||||
|
|
||||||
/* fill buffer with maximum */
|
/* fill buffer with maximum */
|
||||||
volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
|
volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
|
||||||
|
|
||||||
if (volume_id_probe_linux_swap(id, off) == 0)
|
if (volume_id_probe_linux_swap(id, off) == 0)
|
||||||
goto found;
|
goto found;
|
||||||
|
|
||||||
|
if (volume_id_probe_luks(id, off) == 0)
|
||||||
|
goto found;
|
||||||
|
|
||||||
|
if (volume_id_probe_xfs(id, off) == 0)
|
||||||
|
goto found;
|
||||||
|
|
||||||
if (volume_id_probe_ext(id, off) == 0)
|
if (volume_id_probe_ext(id, off) == 0)
|
||||||
goto found;
|
goto found;
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ print the label of a volume
|
|||||||
.TP
|
.TP
|
||||||
\fB\-u\fR
|
\fB\-u\fR
|
||||||
print the uuid of a volume
|
print the uuid of a volume
|
||||||
|
.TP
|
||||||
|
\fB\-\-skip-raid\fR
|
||||||
|
skip probing for raid signatures
|
||||||
|
.TP
|
||||||
|
\fB\-\-probe-all\fR
|
||||||
|
probe for all known signatures to detect possible conflicts
|
||||||
.SH "ENVIRONMENT"
|
.SH "ENVIRONMENT"
|
||||||
.TP
|
.TP
|
||||||
\fBUDEV_LOG\fR
|
\fBUDEV_LOG\fR
|
||||||
|
@ -109,11 +109,14 @@ static void set_str(char *to, const char *from, size_t count)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char help[] = "usage: vol_id [--export|-t|-l|-u] <device>\n"
|
const char help[] = "Usage: vol_id [options] <device>\n"
|
||||||
" --export\n"
|
" --export export key/value pairs\n"
|
||||||
" -t filesystem type\n"
|
" -t filesystem type\n"
|
||||||
" -l filesystem label\n"
|
" -l filesystem label\n"
|
||||||
" -u filesystem uuid\n"
|
" -u filesystem uuid\n"
|
||||||
|
" --skip-raid don't probe for raid\n"
|
||||||
|
" --probe-all find possibly conflicting signatures\n"
|
||||||
|
" --help\n"
|
||||||
"\n";
|
"\n";
|
||||||
enum print_type {
|
enum print_type {
|
||||||
PRINT_EXPORT,
|
PRINT_EXPORT,
|
||||||
@ -125,9 +128,12 @@ int main(int argc, char *argv[])
|
|||||||
static char name[VOLUME_ID_LABEL_SIZE];
|
static char name[VOLUME_ID_LABEL_SIZE];
|
||||||
int i;
|
int i;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
int skip_raid = 0;
|
||||||
|
int probe_all = 0;
|
||||||
const char *node = NULL;
|
const char *node = NULL;
|
||||||
uid_t nobody_uid;
|
uid_t nobody_uid;
|
||||||
gid_t nobody_gid;
|
gid_t nobody_gid;
|
||||||
|
int retval;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
logging_init("vol_id");
|
logging_init("vol_id");
|
||||||
@ -146,6 +152,13 @@ int main(int argc, char *argv[])
|
|||||||
print = PRINT_LABEL;
|
print = PRINT_LABEL;
|
||||||
} else if (strcmp(arg, "-u") == 0) {
|
} else if (strcmp(arg, "-u") == 0) {
|
||||||
print = PRINT_UUID;
|
print = PRINT_UUID;
|
||||||
|
} else if (strcmp(arg, "--skip-raid") == 0) {
|
||||||
|
skip_raid = 1;
|
||||||
|
} else if (strcmp(arg, "--probe-all") == 0) {
|
||||||
|
probe_all = 1;
|
||||||
|
} else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
|
||||||
|
printf(help);
|
||||||
|
goto exit;
|
||||||
} else
|
} else
|
||||||
node = arg;
|
node = arg;
|
||||||
}
|
}
|
||||||
@ -179,15 +192,89 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (volume_id_probe_all(vid, 0, size) == 0)
|
if (probe_all) {
|
||||||
goto print;
|
if (volume_id_probe_linux_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_intel_software_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_lsi_mega_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_via_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_silicon_medley_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_nvidia_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_promise_fasttrack_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_highpoint_45x_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_adaptec_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_jmicron_raid(vid, 0, size) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_vfat(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_linux_swap(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_luks(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_xfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_ext(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_reiserfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_jfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_udf(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_iso9660(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_hfs_hfsplus(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_ufs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_ntfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_cramfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_romfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_hpfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_sysv(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_minix(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_ocfs1(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_ocfs2(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_vxfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_squashfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_netware(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_gfs(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
if (volume_id_probe_gfs2(vid, 0) == 0)
|
||||||
|
printf("%s\n", vid->type);
|
||||||
|
|
||||||
if (print != PRINT_EXPORT)
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skip_raid)
|
||||||
|
retval = volume_id_probe_filesystem(vid, 0, size);
|
||||||
|
else
|
||||||
|
retval = volume_id_probe_all(vid, 0, size);
|
||||||
|
if (retval != 0) {
|
||||||
fprintf(stderr, "%s: unknown volume type\n", node);
|
fprintf(stderr, "%s: unknown volume type\n", node);
|
||||||
rc = 4;
|
rc = 4;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
print:
|
|
||||||
set_str(name, vid->label, sizeof(vid->label));
|
set_str(name, vid->label, sizeof(vid->label));
|
||||||
replace_untrusted_chars(name);
|
replace_untrusted_chars(name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user