Matthew Booth
2012-Dec-11 15:01 UTC
[Libguestfs] Remove 3 unused fields from the filesystem struct
These 3 patches remove unused fields from the filesystem struct, and the inspection code which populates them. The second 2 are fairly trivial NFCs, but the first has the potential for side effects as it entirely removes a couple of matches from the filesystem detection code. A filesystem which was previously matched as X and ignored might conceivably now be matched as Y instead, whereas previously that test would never have happened. This may be a good thing or a bad thing...
Matthew Booth
2012-Dec-11 15:01 UTC
[Libguestfs] [PATCH 1/3] inspect: Remove unused content field from filesystem struct
--- src/guestfs-internal.h | 18 ------------------ src/inspect-fs-cd.c | 1 - src/inspect-fs.c | 44 ++------------------------------------------ 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 4be6e38..c1234ce 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -354,23 +354,6 @@ struct guestfs_h }; /* Per-filesystem data stored for inspect_os. */ -enum inspect_fs_content { - FS_CONTENT_UNKNOWN = 0, - FS_CONTENT_LINUX_ROOT, - FS_CONTENT_WINDOWS_ROOT, - FS_CONTENT_WINDOWS_VOLUME_WITH_APPS, - FS_CONTENT_WINDOWS_VOLUME, - FS_CONTENT_LINUX_BOOT, - FS_CONTENT_LINUX_USR, - FS_CONTENT_LINUX_USR_LOCAL, - FS_CONTENT_LINUX_VAR, - FS_CONTENT_FREEBSD_ROOT, - FS_CONTENT_NETBSD_ROOT, - FS_CONTENT_INSTALLER, - FS_CONTENT_HURD_ROOT, - FS_CONTENT_FREEDOS_ROOT, -}; - enum inspect_os_format { OS_FORMAT_UNKNOWN = 0, OS_FORMAT_INSTALLED, @@ -444,7 +427,6 @@ struct inspect_fs { char *device; int is_mountable; int is_swap; - enum inspect_fs_content content; enum inspect_os_type type; enum inspect_os_distro distro; enum inspect_os_package_format package_format; diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c index 05559b9..6bafb99 100644 --- a/src/inspect-fs-cd.c +++ b/src/inspect-fs-cd.c @@ -507,7 +507,6 @@ guestfs___check_installer_iso (guestfs_h *g, struct inspect_fs *fs, /* Otherwise we matched an ISO, so fill in the fs fields. */ fs->device = safe_strdup (g, device); fs->is_root = 1; - fs->content = FS_CONTENT_INSTALLER; fs->format = OS_FORMAT_INSTALLER; fs->type = osinfo->type; fs->distro = osinfo->distro; diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 2c81e41..706e82e 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -181,15 +181,8 @@ check_filesystem (guestfs_h *g, const char *device, /* Optimize some of the tests by avoiding multiple tests of the same thing. */ int is_dir_etc = guestfs_is_dir (g, "/etc") > 0; int is_dir_bin = guestfs_is_dir (g, "/bin") > 0; - int is_dir_share = guestfs_is_dir (g, "/share") > 0; - - /* Grub /boot? */ - if (guestfs_is_file (g, "/grub/menu.lst") > 0 || - guestfs_is_file (g, "/grub/grub.conf") > 0 || - guestfs_is_file (g, "/grub2/grub.cfg") > 0) - fs->content = FS_CONTENT_LINUX_BOOT; - /* FreeBSD root? */ - else if (is_dir_etc && + + if (is_dir_etc && is_dir_bin && guestfs_is_file (g, "/etc/freebsd-update.conf") > 0 && guestfs_is_file (g, "/etc/fstab") > 0) { @@ -201,7 +194,6 @@ check_filesystem (guestfs_h *g, const char *device, return 0; fs->is_root = 1; - fs->content = FS_CONTENT_FREEBSD_ROOT; fs->format = OS_FORMAT_INSTALLED; if (guestfs___check_freebsd_root (g, fs) == -1) return -1; @@ -218,7 +210,6 @@ check_filesystem (guestfs_h *g, const char *device, 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; @@ -228,7 +219,6 @@ check_filesystem (guestfs_h *g, const char *device, guestfs_is_file (g, "/hurd/hello") > 0 && guestfs_is_file (g, "/hurd/null") > 0) { fs->is_root = 1; - fs->content = FS_CONTENT_HURD_ROOT; fs->format = OS_FORMAT_INSTALLED; /* XXX could be more specific */ if (guestfs___check_hurd_root (g, fs) == -1) return -1; @@ -240,50 +230,21 @@ check_filesystem (guestfs_h *g, const char *device, guestfs_is_dir (g, "/usr/bin") > 0)) && guestfs_is_file (g, "/etc/fstab") > 0) { fs->is_root = 1; - fs->content = FS_CONTENT_LINUX_ROOT; fs->format = OS_FORMAT_INSTALLED; if (guestfs___check_linux_root (g, fs) == -1) return -1; } - /* Linux /usr/local? */ - else if (is_dir_etc && - is_dir_bin && - is_dir_share && - guestfs_exists (g, "/local") == 0 && - guestfs_is_file (g, "/etc/fstab") == 0) - fs->content = FS_CONTENT_LINUX_USR_LOCAL; - /* Linux /usr? */ - else if (is_dir_etc && - is_dir_bin && - is_dir_share && - guestfs_exists (g, "/local") > 0 && - guestfs_is_file (g, "/etc/fstab") == 0) - fs->content = FS_CONTENT_LINUX_USR; - /* Linux /var? */ - else if (guestfs_is_dir (g, "/log") > 0 && - guestfs_is_dir (g, "/run") > 0 && - guestfs_is_dir (g, "/spool") > 0) - fs->content = FS_CONTENT_LINUX_VAR; /* Windows root? */ else if (guestfs___has_windows_systemroot (g) >= 0) { fs->is_root = 1; - fs->content = FS_CONTENT_WINDOWS_ROOT; fs->format = OS_FORMAT_INSTALLED; if (guestfs___check_windows_root (g, fs) == -1) return -1; } - /* Windows volume with installed applications (but not root)? */ - else if (guestfs___is_dir_nocase (g, "/System Volume Information") > 0 && - guestfs___is_dir_nocase (g, "/Program Files") > 0) - fs->content = FS_CONTENT_WINDOWS_VOLUME_WITH_APPS; - /* Windows volume (but not root)? */ - else if (guestfs___is_dir_nocase (g, "/System Volume Information") > 0) - fs->content = FS_CONTENT_WINDOWS_VOLUME; /* FreeDOS? */ else if (guestfs___is_dir_nocase (g, "/FDOS") > 0 && guestfs___is_file_nocase (g, "/FDOS/FREEDOS.BSS") > 0) { fs->is_root = 1; - fs->content = FS_CONTENT_FREEBSD_ROOT; fs->format = OS_FORMAT_INSTALLED; fs->type = OS_TYPE_DOS; fs->distro = OS_DISTRO_FREEDOS; @@ -311,7 +272,6 @@ check_filesystem (guestfs_h *g, const char *device, guestfs_is_file (g, "/amd64/txtsetup.sif") > 0 || guestfs_is_file (g, "/freedos/freedos.ico") > 0)) { fs->is_root = 1; - fs->content = FS_CONTENT_INSTALLER; fs->format = OS_FORMAT_INSTALLER; if (guestfs___check_installer_root (g, fs) == -1) return -1; -- 1.7.11.7
Matthew Booth
2012-Dec-11 15:01 UTC
[Libguestfs] [PATCH 2/3] inspect: Remove unused is_swap field from filesystem struct
--- src/guestfs-internal.h | 1 - src/inspect-fs.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index c1234ce..ffcf91e 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -426,7 +426,6 @@ struct inspect_fs { int is_root; char *device; int is_mountable; - int is_swap; enum inspect_os_type type; enum inspect_os_distro distro; enum inspect_os_package_format package_format; diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 706e82e..2a4d480 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -112,7 +112,6 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, if (extend_fses (g) == -1) return -1; fs = &g->fses[g->nr_fses-1]; - fs->is_swap = 1; return 0; } -- 1.7.11.7
Matthew Booth
2012-Dec-11 15:01 UTC
[Libguestfs] [PATCH 3/3] inspect: Remove unused is_mountable field from filesystem struct
--- po/POTFILES | 1 + src/guestfs-internal.h | 1 - src/inspect-fs.c | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/po/POTFILES b/po/POTFILES index 675cb8d..204bbf5 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -228,6 +228,7 @@ src/actions-5.c src/actions-6.c src/actions-support.c src/actions-variants.c +src/actions.c src/alloc.c src/appliance.c src/bindtests.c diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index ffcf91e..3e197ec 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -425,7 +425,6 @@ enum inspect_os_package_management { struct inspect_fs { int is_root; char *device; - int is_mountable; enum inspect_os_type type; enum inspect_os_distro distro; enum inspect_os_package_format package_format; diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 2a4d480..c09c046 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -175,7 +175,6 @@ check_filesystem (guestfs_h *g, const char *device, struct inspect_fs *fs = &g->fses[g->nr_fses-1]; fs->device = safe_strdup (g, device); - fs->is_mountable = 1; /* Optimize some of the tests by avoiding multiple tests of the same thing. */ int is_dir_etc = guestfs_is_dir (g, "/etc") > 0; -- 1.7.11.7
Richard W.M. Jones
2012-Dec-11 16:34 UTC
[Libguestfs] Remove 3 unused fields from the filesystem struct
On Tue, Dec 11, 2012 at 03:01:09PM +0000, Matthew Booth wrote:> These 3 patches remove unused fields from the filesystem struct, and the > inspection code which populates them. The second 2 are fairly trivial NFCs, but > the first has the potential for side effects as it entirely removes a couple of > matches from the filesystem detection code. A filesystem which was previously > matched as X and ignored might conceivably now be matched as Y instead, whereas > previously that test would never have happened. This may be a good thing or a > bad thing...Thanks - I am about to push all these. I made a couple of minor changes as outlined on IRC. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora