exit 1
fi
+cat <<'EOF' > test.fstab
+/dev/VG/Root / ext2 default 0 0
+
+# cciss device which requires a hint
+/dev/cciss/c1d3p1 /boot ext2 default 0 0
+
+# cciss device, whole disk
+/dev/cciss/c1d3 /var ext2 default 0 0
+EOF
+
+$guestfish -a test1.img <<'EOF'
+ run
+ mount-options "" /dev/VG/Root /
+ upload test.fstab /etc/fstab
+EOF
+
+$guestfish <<'EOF' > test.output
+ add-drive-opts test1.img readonly:true name:cciss/c1d3
+ run
+ inspect-os
+ inspect-get-mountpoints /dev/VG/Root
+EOF
+
+if [ "$(cat test.output)" != "/dev/VG/Root
+/: /dev/VG/Root
+/boot: /dev/vda1
+/var: /dev/vda" ]; then
+ echo "$0: error: unexpected output from inspect-get-mountpoints command"
+ cat test.output
+ exit 1
+fi
+
rm test.fstab
rm test1.img
rm test.output
static pcre *re_major_minor;
static pcre *re_aug_seq;
static pcre *re_xdev;
+static pcre *re_cciss;
static pcre *re_first_partition;
static pcre *re_freebsd;
static pcre *re_netbsd;
COMPILE (re_major_minor, "(\\d+)\\.(\\d+)", 0);
COMPILE (re_aug_seq, "/\\d+$", 0);
COMPILE (re_xdev, "^/dev/(h|s|v|xv)d([a-z]+)(\\d*)$", 0);
+ COMPILE (re_cciss, "^/dev/(cciss/c\\d+d\\d+)(?:p(\\d+))?$", 0);
COMPILE (re_freebsd, "^/dev/ad(\\d+)s(\\d+)([a-z])$", 0);
COMPILE (re_netbsd, "^NetBSD (\\d+)\\.(\\d+)", 0);
}
pcre_free (re_major_minor);
pcre_free (re_aug_seq);
pcre_free (re_xdev);
+ pcre_free (re_cciss);
pcre_free (re_freebsd);
pcre_free (re_netbsd);
}
free (part);
guestfs___free_string_list (devices);
}
+ else if (match2 (g, spec, re_cciss, &disk, &part)) {
+ /* disk: (cciss/c\d+d\d+)
+ * part: (\d+)? */
+ char **devices = guestfs_list_devices (g);
+ if (devices == NULL)
+ return NULL;
+
+ /* Check any hints we were passed for a non-heuristic mapping */
+ size_t i = 0;
+ struct drive *drive = g->drives;
+ while (drive) {
+ if (drive->name && STREQ(drive->name, disk)) {
+ if (part) {
+ device = safe_asprintf (g, "%s%s", devices[i], part);
+ } else {
+ device = safe_strdup (g, devices[i]);
+ }
+ break;
+ }
+
+ i++; drive = drive->next;
+ }
+
+ /* We don't try to guess mappings for cciss devices */
+
+ free (disk);
+ free (part);
+ guestfs___free_string_list (devices);
+ }
else if (match3 (g, spec, re_freebsd, &disk, &slice, &part)) {
/* FreeBSD disks are organized quite differently. See:
* http://www.freebsd.org/doc/handbook/disk-organization.html