FS_CONTENT_LINUX_USR_LOCAL,
FS_CONTENT_LINUX_VAR,
FS_CONTENT_FREEBSD_ROOT,
+ FS_CONTENT_NETBSD_ROOT,
FS_CONTENT_INSTALLER,
};
OS_TYPE_LINUX,
OS_TYPE_WINDOWS,
OS_TYPE_FREEBSD,
+ OS_TYPE_NETBSD,
};
enum inspect_os_distro {
extern int guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs);
extern int guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs);
extern int guestfs___check_freebsd_root (guestfs_h *g, struct inspect_fs *fs);
+extern int guestfs___check_netbsd_root (guestfs_h *g, struct inspect_fs *fs);
extern int guestfs___has_windows_systemroot (guestfs_h *g);
extern int guestfs___check_windows_root (guestfs_h *g, struct inspect_fs *fs);
#endif
char *ret;
switch (fs->type) {
+ case OS_TYPE_FREEBSD: ret = safe_strdup (g, "freebsd"); break;
case OS_TYPE_LINUX: ret = safe_strdup (g, "linux"); break;
+ case OS_TYPE_NETBSD: ret = safe_strdup (g, "netbsd"); break;
case OS_TYPE_WINDOWS: ret = safe_strdup (g, "windows"); break;
- case OS_TYPE_FREEBSD: ret = safe_strdup (g, "freebsd"); break;
case OS_TYPE_UNKNOWN: default: ret = safe_strdup (g, "unknown"); break;
}
if (guestfs___check_freebsd_root (g, fs) == -1)
return -1;
}
+ else if (is_dir_etc &&
+ is_dir_bin &&
+ guestfs_is_file (g, "/etc/fstab") > 0 &&
+ guestfs_is_file (g, "/etc/release") > 0) {
+ /* Ignore /dev/sda1 which is a shadow of the real root filesystem
+ * that is probably /dev/sda5 (see:
+ * http://www.freebsd.org/doc/handbook/disk-organization.html)
+ */
+ if (match (g, device, re_first_partition))
+ return 0;
+
+ fs->is_root = 1;
+ fs->content = FS_CONTENT_NETBSD_ROOT;
+ fs->format = OS_FORMAT_INSTALLED;
+ if (guestfs___check_netbsd_root (g, fs) == -1)
+ return -1;
+ }
/* Linux root? */
else if (is_dir_etc &&
is_dir_bin &&
static pcre *re_xdev;
static pcre *re_first_partition;
static pcre *re_freebsd;
+static pcre *re_netbsd;
static void compile_regexps (void) __attribute__((constructor));
static void free_regexps (void) __attribute__((destructor));
COMPILE (re_aug_seq, "/\\d+$", 0);
COMPILE (re_xdev, "^/dev/(?:h|s|v|xv)d([a-z]\\d*)$", 0);
COMPILE (re_freebsd, "^/dev/ad(\\d+)s(\\d+)([a-z])$", 0);
+ COMPILE (re_netbsd, "^NetBSD (\\d+)\\.(\\d+)", 0);
}
static void
pcre_free (re_aug_seq);
pcre_free (re_xdev);
pcre_free (re_freebsd);
+ pcre_free (re_netbsd);
}
static void check_architecture (guestfs_h *g, struct inspect_fs *fs);
return 0;
}
+/* The currently mounted device is maybe to be a *BSD root. */
+int
+guestfs___check_netbsd_root (guestfs_h *g, struct inspect_fs *fs)
+{
+
+ if (guestfs_exists (g, "/etc/release") > 0) {
+ char *major, *minor;
+ if (parse_release_file (g, fs, "/etc/release") == -1)
+ return -1;
+
+ if (match2 (g, fs->product_name, re_netbsd, &major, &minor)) {
+ fs->type = OS_TYPE_NETBSD;
+ fs->major_version = guestfs___parse_unsigned_int (g, major);
+ free (major);
+ if (fs->major_version == -1) {
+ free (minor);
+ return -1;
+ }
+ fs->minor_version = guestfs___parse_unsigned_int (g, minor);
+ free (minor);
+ if (fs->minor_version == -1)
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+
+ /* Determine the architecture. */
+ check_architecture (g, fs);
+
+ /* We already know /etc/fstab exists because it's part of the test above. */
+ if (inspect_with_augeas (g, fs, "/etc/fstab", check_fstab) == -1)
+ return -1;
+
+ /* Determine hostname. */
+ if (check_hostname_unix (g, fs) == -1)
+ return -1;
+
+ return 0;
+}
+
+
static void
check_architecture (guestfs_h *g, struct inspect_fs *fs)
{
break;
case OS_TYPE_FREEBSD:
+ case OS_TYPE_NETBSD:
/* /etc/rc.conf contains the hostname, but there is no Augeas lens
* for this file.
*/