[PATCH] virt-cat: remove the useless "h" option
by Wanlong Gao
"h" option is not enabled in virt-cat, remove it.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
cat/virt-cat.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/cat/virt-cat.c b/cat/virt-cat.c
index 2a6b64f..5ea461e 100644
--- a/cat/virt-cat.c
+++ b/cat/virt-cat.c
@@ -158,9 +158,6 @@ main (int argc, char *argv[])
OPTION_d;
break;
- case 'h':
- usage (EXIT_SUCCESS);
-
case 'v':
OPTION_v;
break;
--
1.7.12.1.401.gb5d156c
12 years, 2 months
guestfish hang when exec command.
by xuanmao_001
Hi,
I have some issues with libguestfs. I download the libguestfs-0.18.3 source code and read the README file.
it requested qemu >= 0.13, my qemu version is qemu-1.0.1
requested kernel version >= 2.6.34, my kernel version is 3.1.4
the most of requirement for compiling I reached. but I completed compiltion and executed command.
the guestfish hang there.
the following was my operating steps:
tar -Jxvf appliance-<VERSION>.tar.xz
Then copy all four files:
* kernel
* initrd
* root
* README.fixed
into a directory somewhere, eg. /usr/local/lib/guestfs/appliance/
Then build libguestfs (>= 1.16.7 or >= 1.17.10) from source, disabling
the normal appliance and daemon:
./configure --disable-appliance --disable-daemon
make
make install
Set LIBGUESTFS_PATH to the path where you unpacked these files, eg:
export LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance/
then executed command:
virt-copy-out -d GuestName 'win:c:\windows\system32\config' .
the command hang here.
Is there something going wrong? give me some help, thanks!
xuanmao_001
12 years, 2 months
[PATCH V1] NEW API:ext:mke2fs
by Wanlong Gao
New api mke2fs for full configuration of filesystem.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/ext2.c | 452 +++++++++++++++++++++++++++++++++++++++++
generator/generator_actions.ml | 18 ++
gobject/Makefile.inc | 6 +-
src/MAX_PROC_NR | 2 +-
4 files changed, 475 insertions(+), 3 deletions(-)
diff --git a/daemon/ext2.c b/daemon/ext2.c
index 40b36d2..ee87d05 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -811,3 +811,455 @@ do_set_e2generation (const char *filename, int64_t generation)
return 0;
}
+
+int
+do_mke2fs (const char *device,
+ int checkbadblock, const char *badblockfile,
+ int64_t blocksize, int directwrite,
+ int64_t fragsize, int forcecreate,
+ int64_t blockspergroup, int64_t numberofgroups,
+ int64_t bytesperinode, int64_t inodesize,
+ int withjournal, int64_t journalsize,
+ const char *journaldevice, const char *newvolumelabel,
+ int reservedblockspercentage, const char *lastmounteddir,
+ int64_t numberofinodes, const char *creatoros,
+ int writesbandgrouponly,
+ const char *fstype, const char *usagetype,
+ const char *fsuuid, int mmpupdateinterval,
+ int64_t stridesize, int64_t stripewidth,
+ int64_t maxonlineresize, int lazyitableinit,
+ int lazyjournalinit, int testfs,
+ int discard, int quotatype,
+ int dirindex, int extent, int filetype,
+ int flexbg, int hasjournal, int journaldev,
+ int largefile, int quota, int resizeinode,
+ int sparsesuper, int uninitbg,
+ int64_t blockscount)
+{
+ int r;
+ char *err = NULL;
+ const char *argv[MAX_ARGS];
+ char blocksize_s[64];
+ char fragsize_s[64];
+ char blockspergroup_s[64];
+ char numberofgroups_s[64];
+ char bytesperinode_s[64];
+ char inodesize_s[64];
+ char journalsize_s[64];
+ char journaldevice_s[256];
+ char reservedblockspercentage_s[64];
+ char numberofinodes_s[64];
+ char mmpupdateinterval_s[84];
+ char stridesize_s[74];
+ char stripewidth_s[84];
+ char maxonlineresize_s[74];
+ char blockscount_s[64];
+ size_t i = 0;
+ int feature = 0;
+ char features[256];
+
+ ADD_ARG (argv, i, str_mke2fs);
+
+ if (optargs_bitmask & GUESTFS_MKE2FS_CHECKBADBLOCK_BITMASK) {
+ if (checkbadblock)
+ ADD_ARG (argv, i, "-c");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_BADBLOCKFILE_BITMASK) {
+ if (badblockfile) {
+ ADD_ARG (argv, i, "-l");
+ ADD_ARG (argv, i, badblockfile);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_BLOCKSIZE_BITMASK) {
+ if (blocksize < 0) {
+ reply_with_error ("blocksize must be >= 0");
+ goto error;
+ }
+ snprintf (blocksize_s, sizeof blocksize_s, "%" PRIi64, blocksize);
+ ADD_ARG (argv, i, "-b");
+ ADD_ARG (argv, i, blocksize_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_DIRECTWRITE_BITMASK) {
+ if (directwrite)
+ ADD_ARG (argv, i, "-D");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_FRAGSIZE_BITMASK) {
+ if (fragsize < 0) {
+ reply_with_error ("fragsize must be >= 0");
+ goto error;
+ }
+ snprintf (fragsize_s, sizeof fragsize_s, "%" PRIi64, fragsize);
+ ADD_ARG (argv, i, "-f");
+ ADD_ARG (argv, i, fragsize_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_FORCECREATE_BITMASK) {
+ if (forcecreate)
+ ADD_ARG (argv, i, "-F");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_BLOCKSPERGROUP_BITMASK) {
+ if (blockspergroup < 0) {
+ reply_with_error ("blockspergroup must be >= 0");
+ goto error;
+ }
+ snprintf (blockspergroup_s, sizeof blockspergroup_s,
+ "%" PRIi64, blockspergroup);
+ ADD_ARG (argv, i, "-g");
+ ADD_ARG (argv, i, blockspergroup_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_NUMBEROFGROUPS_BITMASK) {
+ if (numberofgroups < 0) {
+ reply_with_error ("numberofgroups must be >= 0");
+ goto error;
+ }
+ snprintf (numberofgroups_s, sizeof numberofgroups_s,
+ "%" PRIi64, numberofgroups);
+ ADD_ARG (argv, i, "-G");
+ ADD_ARG (argv, i, numberofgroups_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_BYTESPERINODE_BITMASK) {
+ if (bytesperinode < 0) {
+ reply_with_error ("bytesperinode must be >= 0");
+ goto error;
+ }
+ snprintf (bytesperinode_s, sizeof bytesperinode_s, "%" PRIi64, bytesperinode);
+ ADD_ARG (argv, i, "-i");
+ ADD_ARG (argv, i, bytesperinode_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_INODESIZE_BITMASK) {
+ if (inodesize < 0) {
+ reply_with_error ("inodesize must be >= 0");
+ goto error;
+ }
+ snprintf (inodesize_s, sizeof inodesize_s, "%" PRIi64, inodesize);
+ ADD_ARG (argv, i, "-I");
+ ADD_ARG (argv, i, inodesize_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_WITHJOURNAL_BITMASK) {
+ if (withjournal)
+ ADD_ARG (argv, i, "-j");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_JOURNALSIZE_BITMASK) {
+ if (journalsize < 0) {
+ reply_with_error ("journalsize must be >= 0");
+ goto error;
+ }
+ snprintf (journalsize_s, sizeof journalsize_s,
+ "size=" "%" PRIi64, journalsize);
+ ADD_ARG (argv, i, "-J");
+ ADD_ARG (argv, i, journalsize_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_JOURNALDEVICE_BITMASK) {
+ if (journaldevice) {
+ snprintf (journaldevice_s, sizeof journaldevice_s,
+ "device=%s", journaldevice);
+ ADD_ARG (argv, i, "-J");
+ ADD_ARG (argv, i, journaldevice_s);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_NEWVOLUMELABEL_BITMASK) {
+ if (newvolumelabel) {
+ ADD_ARG (argv, i, "-L");
+ ADD_ARG (argv, i, newvolumelabel);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_RESERVEDBLOCKSPERCENTAGE_BITMASK) {
+ if (reservedblockspercentage < 0) {
+ reply_with_error ("reservedblockspercentage must be >= 0");
+ goto error;
+ }
+ snprintf (reservedblockspercentage_s, sizeof reservedblockspercentage_s,
+ "%" PRIi32, reservedblockspercentage);
+ ADD_ARG (argv, i, "-m");
+ ADD_ARG (argv, i, reservedblockspercentage_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_LASTMOUNTEDDIR_BITMASK) {
+ if (lastmounteddir) {
+ ADD_ARG (argv, i, "-M");
+ ADD_ARG (argv, i, lastmounteddir);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_NUMBEROFINODES_BITMASK) {
+ if (numberofinodes < 0) {
+ reply_with_error ("numberofinodes must be >= 0");
+ goto error;
+ }
+ snprintf (numberofinodes_s, sizeof numberofinodes_s,
+ "%" PRIi64, numberofinodes);
+ ADD_ARG (argv, i, "-N");
+ ADD_ARG (argv, i, numberofinodes_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_CREATOROS_BITMASK) {
+ if (creatoros) {
+ ADD_ARG (argv, i, "-o");
+ ADD_ARG (argv, i, creatoros);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_WRITESBANDGROUPONLY_BITMASK) {
+ if (writesbandgrouponly)
+ ADD_ARG (argv, i, "-S");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_FSTYPE_BITMASK) {
+ if (fstype) {
+ ADD_ARG (argv, i, "-t");
+ ADD_ARG (argv, i, fstype);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_USAGETYPE_BITMASK) {
+ if (usagetype) {
+ ADD_ARG (argv, i, "-T");
+ ADD_ARG (argv, i, usagetype);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_FSUUID_BITMASK) {
+ if (fsuuid) {
+ ADD_ARG (argv, i, "-U");
+ ADD_ARG (argv, i, fsuuid);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_MMPUPDATEINTERVAL_BITMASK) {
+ if (mmpupdateinterval < 0) {
+ reply_with_error ("mmpupdateinterval must be >= 0");
+ goto error;
+ }
+ snprintf (mmpupdateinterval_s, sizeof mmpupdateinterval_s,
+ "mmp_update_interval=" "%" PRIi32, mmpupdateinterval);
+ ADD_ARG (argv, i, "-E");
+ ADD_ARG (argv, i, mmpupdateinterval_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_STRIDESIZE_BITMASK) {
+ if (stridesize < 0) {
+ reply_with_error ("stridesize must be >= 0");
+ goto error;
+ }
+ snprintf (stridesize_s, sizeof stridesize_s,
+ "stride=" "%" PRIi64, stridesize);
+ ADD_ARG (argv, i, "-E");
+ ADD_ARG (argv, i, stridesize_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_STRIPEWIDTH_BITMASK) {
+ if (stripewidth< 0) {
+ reply_with_error ("stripewidth must be >= 0");
+ goto error;
+ }
+ snprintf (stripewidth_s, sizeof stripewidth_s,
+ "stripe_width=" "%" PRIi64, stripewidth);
+ ADD_ARG (argv, i, "-E");
+ ADD_ARG (argv, i, stripewidth_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_MAXONLINERESIZE_BITMASK) {
+ if (maxonlineresize < 0) {
+ reply_with_error ("maxonlineresize must be >= 0");
+ goto error;
+ }
+ snprintf (maxonlineresize_s, sizeof maxonlineresize_s,
+ "resize=" "%" PRIi64, maxonlineresize);
+ ADD_ARG (argv, i, "-E");
+ ADD_ARG (argv, i, maxonlineresize_s);
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_LAZYITABLEINIT_BITMASK) {
+ ADD_ARG (argv, i, "-E");
+ if (lazyitableinit)
+ ADD_ARG (argv, i, "lazy_itable_init=1");
+ else
+ ADD_ARG (argv, i, "lazy_itable_init=0");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_LAZYJOURNALINIT_BITMASK) {
+ ADD_ARG (argv, i, "-E");
+ if (lazyjournalinit)
+ ADD_ARG (argv, i, "lazy_journal_init=1");
+ else
+ ADD_ARG (argv, i, "lazy_journal_init=0");
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_TESTFS_BITMASK) {
+ if (testfs) {
+ ADD_ARG (argv, i, "-E");
+ ADD_ARG (argv, i, "test_fs");
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_DISCARD_BITMASK) {
+ ADD_ARG (argv, i, "-E");
+ if (discard)
+ ADD_ARG (argv, i, "discard");
+ else
+ ADD_ARG (argv, i, "nodiscard");
+ }
+
+ if (optargs_bitmask & GUESTFS_MKE2FS_DIRINDEX_BITMASK) {
+ if (dirindex)
+ strncat (features, "dir_index", 9);
+ else
+ strncat (features, "^dir_index", 10);
+ feature++;
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_EXTENT_BITMASK) {
+ if (feature == 0) {
+ if (extent)
+ strncat (features, "extent", 6);
+ else
+ strncat (features, "^extent", 7);
+ feature++;
+ } else {
+ if (extent)
+ strncat (features, ",extent", 7);
+ else
+ strncat (features, ",^extent", 8);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_FILETYPE_BITMASK) {
+ if (feature == 0) {
+ if (filetype)
+ strncat (features, "filetype", 8);
+ else
+ strncat (features, "^filetype", 9);
+ feature++;
+ } else {
+ if (filetype)
+ strncat (features, ",filetype", 9);
+ else
+ strncat (features, ",^filetype", 10);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_FLEXBG_BITMASK) {
+ if (feature == 0) {
+ if (flexbg)
+ strncat (features, "flex_bg", 7);
+ else
+ strncat (features, "^flex_bg", 8);
+ feature++;
+ } else {
+ if (flexbg)
+ strncat (features, ",flex_bg", 8);
+ else
+ strncat (features, ",^flex_bg", 9);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_HASJOURNAL_BITMASK) {
+ if (feature == 0) {
+ if (hasjournal)
+ strncat (features, "has_journal", 11);
+ else
+ strncat (features, "^has_journal", 12);
+ feature++;
+ } else {
+ if (hasjournal)
+ strncat (features, ",has_journal", 12);
+ else
+ strncat (features, ",^has_journal", 13);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_JOURNALDEV_BITMASK) {
+ if (feature == 0) {
+ if (journaldev)
+ strncat (features, "journal_dev", 11);
+ else
+ strncat (features, "^journal_dev", 12);
+ feature++;
+ } else {
+ if (journaldev)
+ strncat (features, ",journal_dev", 12);
+ else
+ strncat (features, ",^journal_dev", 13);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_LARGEFILE_BITMASK) {
+ if (feature == 0) {
+ if (largefile)
+ strncat (features, "large_file", 10);
+ else
+ strncat (features, "^large_file", 11);
+ feature++;
+ } else {
+ if (largefile)
+ strncat (features, ",large_file", 11);
+ else
+ strncat (features, ",^large_file", 12);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_QUOTA_BITMASK) {
+ if (feature == 0) {
+ if (quota)
+ strncat (features, "quota", 5);
+ else
+ strncat (features, "^quota", 6);
+ feature++;
+ } else {
+ if (quota)
+ strncat (features, ",quota", 6);
+ else
+ strncat (features, ",^quota", 7);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_RESIZEINODE_BITMASK) {
+ if (feature == 0) {
+ if (resizeinode)
+ strncat (features, "resize_inode", 12);
+ else
+ strncat (features, "^resize_inode", 13);
+ feature++;
+ } else {
+ if (resizeinode)
+ strncat (features, ",resize_inode", 13);
+ else
+ strncat (features, ",^resize_inode", 14);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_SPARSESUPER_BITMASK) {
+ if (feature == 0) {
+ if (sparsesuper)
+ strncat (features, "sparse_super", 12);
+ else
+ strncat (features, "^sparse_super", 13);
+ feature++;
+ } else {
+ if (sparsesuper)
+ strncat (features, ",sparse_super", 13);
+ else
+ strncat (features, ",^sparse_super", 14);
+ }
+ }
+ if (optargs_bitmask & GUESTFS_MKE2FS_UNINITBG_BITMASK) {
+ if (feature == 0) {
+ if (uninitbg)
+ strncat (features, "uninit_bg", 9);
+ else
+ strncat (features, "^uninit_bg", 10);
+ feature++;
+ } else {
+ if (uninitbg)
+ strncat (features, ",uninit_bg", 10);
+ else
+ strncat (features, ",^uninit_bg", 11);
+ }
+ }
+
+ if (feature != 0) {
+ ADD_ARG (argv, i, "-O");
+ ADD_ARG (argv, i, features);
+ }
+
+ ADD_ARG (argv, i, device);
+
+ if (optargs_bitmask & GUESTFS_MKE2FS_BLOCKSCOUNT_BITMASK) {
+ if (blockscount < 0) {
+ reply_with_error ("blockscount must be >= 0");
+ goto error;
+ }
+ snprintf (blockscount_s, sizeof blockscount_s, "%" PRIi64, blockscount);
+ ADD_ARG (argv, i, blockscount_s);
+ }
+
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (NULL, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ goto error;
+ }
+
+ free (err);
+ return 0;
+
+error:
+ if (err) free (err);
+ return -1;
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 0033e3a..2c71263 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -9710,6 +9710,24 @@ the resulting filesystem may be inconsistent or corrupt.
The returned status indicates whether filesystem corruption was
detected (returns C<1>) or was not detected (returns C<0>)." };
+ { defaults with
+ name = "mke2fs";
+ style = RErr, [Device "device"], [OBool "checkbadblock"; OString "badblockfile"; OInt64 "blocksize"; OBool "directwrite"; OInt64 "fragsize"; OBool "forcecreate"; OInt64 "blockspergroup"; OInt64 "numberofgroups"; OInt64 "bytesperinode"; OInt64 "inodesize"; OBool "withjournal"; OInt64 "journalsize"; OString "journaldevice"; OString "newvolumelabel"; OInt "reservedblockspercentage"; OString "lastmounteddir"; OInt64 "numberofinodes"; OString "creatoros"; OBool "writesbandgrouponly"; OString "fstype"; OString "usagetype"; OString "fsuuid"; OInt "mmpupdateinterval"; OInt64 "stridesize"; OInt64 "stripewidth"; OInt64 "maxonlineresize"; OBool "lazyitableinit"; OBool "lazyjournalinit"; OBool "testfs"; OBool "discard"; OBool "quotatype"; OBool "dirindex"; OBool "extent"; OBool "filetype"; OBool "flexbg"; OBool "hasjournal"; OBool "journaldev"; OBool "largefile"; OBool "quota"; OBool "resizeinode"; OBool "sparsesuper"; OBool "uninitbg"; OInt64 "blockscount"];
+ proc_nr = Some 367;
+ tests = [
+ InitEmpty, IfAvailable "ext2", TestRun (
+ [["part_disk"; "/dev/sda"; "mbr"];
+ ["mke2fs"; "/dev/sda1"; ""; "NOARG"; ""; ""; ""; ""; ""; ""; ""; ""; "true"; ""; "NOARG"; "NOARG"; ""; "NOARG"; ""; "NOARG"; ""; "ext4"; "NOARG"; "NOARG"; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""];
+ ])
+ ];
+ shortdesc = "create an ext2/ext3/ext4 filesystem on C<device>";
+ longdesc = "\
+C<mke2fs> is used to create an ext2, ext3, or ext4 filesystem,
+usually in a disk partition. C<device> is the special file corresponding
+to the device (e.g /dev/sdXX). C<blockscount> is the number of blocks
+on C<device>. If omitted, C<mke2fs> automagically figures the file system
+size." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index ba41b48..de8e1e7 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -78,7 +78,8 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-rsync_out.h \
include/guestfs-gobject/optargs-xfs_admin.h \
include/guestfs-gobject/optargs-hivex_open.h \
- include/guestfs-gobject/optargs-xfs_repair.h
+ include/guestfs-gobject/optargs-xfs_repair.h \
+ include/guestfs-gobject/optargs-mke2fs.h
guestfs_gobject_sources= \
src/session.c \
@@ -138,4 +139,5 @@ guestfs_gobject_sources= \
src/optargs-rsync_out.c \
src/optargs-xfs_admin.c \
src/optargs-hivex_open.c \
- src/optargs-xfs_repair.c
+ src/optargs-xfs_repair.c \
+ src/optargs-mke2fs.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 4203007..526204c 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-366
+367
--
1.7.12
12 years, 3 months
[PATCH] Fix tests/bigdirs/test-big-dirs.pl to use mke2fs
by Wanlong Gao
Let tests/bigdirs/test-big-dirs.pl uses mke2fs to create small
inode ratio files.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
TODO | 6 ------
tests/bigdirs/test-big-dirs.pl | 18 ++++--------------
2 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/TODO b/TODO
index 1ff661f..1cde423 100644
--- a/TODO
+++ b/TODO
@@ -565,12 +565,6 @@ the p.o.v of the API and ABI.
- guestfs_readdir
-mke2fs
-------
-
-Add a mke2fs API call allowing full configuration of filesystems.
-Then fix tests/bigdirs/test-big-dirs.pl to use it.
-
hivex
-----
diff --git a/tests/bigdirs/test-big-dirs.pl b/tests/bigdirs/test-big-dirs.pl
index 052163b..35fbc90 100755
--- a/tests/bigdirs/test-big-dirs.pl
+++ b/tests/bigdirs/test-big-dirs.pl
@@ -22,23 +22,12 @@ use warnings;
use Sys::Guestfs;
-# Skip this test on 32 bit machines, since we cannot create a large
-# enough file below.
-if (~1 == 4294967294) {
- print STDERR "$0: tested skipped because this is a 32 bit machine\n";
- exit 77
-}
-
my $g = Sys::Guestfs->new ();
-# Create a 16 GB test file. Don't worry, it's sparse.
-#
-# It has to be this big because the 'defaults' configuration of mke2fs
-# will choose a default inode ratio of 16K, and in order to create a
-# million files that means we have to have the disk be >= 16K * 1000000
-# bytes in size.
+# Create a 2 GB test file. Don't worry, it's sparse.
+
my $nr_files = 1000000;
-my $image_size = 16*1024*1024*1024;
+my $image_size = 2*1024*1024*1024;
unlink "test.img";
open FILE, ">test.img" or die "test.img: $!";
@@ -51,6 +40,7 @@ $g->launch ();
$g->part_disk ("/dev/sda", "mbr");
$g->mkfs ("ext4", "/dev/sda1");
+$g->mke2fs ("/dev/sda1", "fstype:ext4", "bytesperinode:2048");
$g->mount ("/dev/sda1", "/");
my %df = $g->statvfs ("/");
--
1.7.12
12 years, 3 months
[PATCH] sysprep: handle at jobs in cron-spool operation
by Olaf Hering
cron-spool claims to remove at jobs, but it has no code to actually do
that. Add patterns to remove files in known at spool locations.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
This patch is only compile tested!
sysprep/sysprep_operation_cron_spool.ml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml
index 5284660..e96832c 100644
--- a/sysprep/sysprep_operation_cron_spool.ml
+++ b/sysprep/sysprep_operation_cron_spool.ml
@@ -23,6 +23,12 @@ module G = Guestfs
let cron_spool_perform g root =
Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*");
+ Array.iter g#rm (g#glob_expand "/var/spool/atjobs/*");
+ Array.iter g#rm (g#glob_expand "/var/spool/atjobs/.SEQ");
+ Array.iter g#rm (g#glob_expand "/var/spool/atspool/*");
+ Array.iter g#rm (g#glob_expand "/var/spool/at/*");
+ Array.iter g#rm (g#glob_expand "/var/spool/at/.SEQ");
+ Array.iter g#rm (g#glob_expand "/var/spool/at/spool/*");
[]
let cron_spool_op = {
--
1.7.12
12 years, 3 months
[PATCH] sysprep: handle distro specific sysv scripts
by Olaf Hering
Currently firstboot would only work on redhat-based images.
Handle redhat-based, suse-based and debian guests, error out in case of an
unknown distro.
Update firstboot.sh:
- make sure scripts exists and can be executed
- add LSB header to avoid insserv warnings later on
- run script only if called with "start"
Update functions, pass only required options.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
diff --git a/sysprep/firstboot.ml b/sysprep/firstboot.ml
index 97cd8a9..719ab38 100644
--- a/sysprep/firstboot.ml
+++ b/sysprep/firstboot.ml
@@ -28,14 +28,35 @@ let firstboot_dir = "/usr/lib/virt-sysprep"
let firstboot_sh = sprintf "\
#!/bin/sh -
+### BEGIN INIT INFO
+# Provides: virt-sysprep
+# Required-Start: $null
+# Should-Start: $all
+# Required-Stop: $null
+# Should-Stop: $all
+# Default-Start: 2 3 5
+# Default-Stop: 0 1 6
+# Short-Description: Start scripts to run once at next boot
+# Description: Start scripts to run once at next boot
+# These scripts run the first time the guest boots,
+# and then are deleted. Output or errors from the scripts
+# are written to ~root/virt-sysprep-firstboot.log.
+### END INIT INFO
+
d=%s/scripts
logfile=~root/virt-sysprep-firstboot.log
-for f in $d/* ; do
- echo '=== Running' $f '===' >>$logfile
- $f >>$logfile 2>&1
- rm $f
-done
+if test \"$1\" = \"start\"
+then
+ for f in $d/* ; do
+ if test -x \"$f\"
+ then
+ echo '=== Running' $f '===' >>$logfile
+ $f >>$logfile 2>&1
+ rm -f $f
+ fi
+ done
+fi
" firstboot_dir
let firstboot_service = sprintf "\
@@ -56,7 +77,7 @@ WantedBy=default.target
let failed fs =
ksprintf (fun msg -> failwith (s_"firstboot: failed: " ^ msg)) fs
-let rec install_service g root =
+let rec install_service g distro =
g#mkdir_p firstboot_dir;
g#mkdir_p (sprintf "%s/scripts" firstboot_dir);
g#write (sprintf "%s/firstboot.sh" firstboot_dir) firstboot_sh;
@@ -64,18 +85,18 @@ let rec install_service g root =
(* systemd, else assume sysvinit *)
if g#is_dir "/etc/systemd" then
- install_systemd_service g root
+ install_systemd_service g
else
- install_sysvinit_service g root
+ install_sysvinit_service g distro
(* Install the systemd firstboot service, if not installed already. *)
-and install_systemd_service g root =
+and install_systemd_service g =
g#write (sprintf "%s/firstboot.service" firstboot_dir) firstboot_service;
g#mkdir_p "/etc/systemd/system/default.target.wants";
g#ln_sf (sprintf "%s/firstboot.service" firstboot_dir)
"/etc/systemd/system/default.target.wants"
-and install_sysvinit_service g root =
+and install_sysvinit_redhat g =
g#mkdir_p "/etc/rc.d/rc2.d";
g#mkdir_p "/etc/rc.d/rc3.d";
g#mkdir_p "/etc/rc.d/rc5.d";
@@ -86,12 +107,51 @@ and install_sysvinit_service g root =
g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
"/etc/rc.d/rc5.d/99virt-sysprep-firstboot"
+(* Make firstboot.sh look like a runlevel script to avoid insserv warnings. *)
+and install_sysvinit_suse g =
+ g#mkdir_p "/etc/init.d/rc2.d";
+ g#mkdir_p "/etc/init.d/rc3.d";
+ g#mkdir_p "/etc/init.d/rc5.d";
+ g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
+ "/etc/init.d/virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc2.d/S99virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc3.d/S99virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc5.d/S99virt-sysprep-firstboot"
+
+and install_sysvinit_debian g =
+ g#mkdir_p "/etc/init.d";
+ g#mkdir_p "/etc/rc.d/rc2.d";
+ g#mkdir_p "/etc/rc.d/rc3.d";
+ g#mkdir_p "/etc/rc.d/rc5.d";
+ g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
+ "/etc/init.d/virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc2.d/S99virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc3.d/S99virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc5.d/S99virt-sysprep-firstboot"
+
+and install_sysvinit_service g distro =
+ match distro with
+ | ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ install_sysvinit_redhat g
+ | ("opensuse"|"sles"|"suse-based") ->
+ install_sysvinit_suse g
+ | "debian" ->
+ install_sysvinit_debian g
+ | _ ->
+ failed "guest type %s is not supported" distro
+
let add_firstboot_script g root id content =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
| "linux", _ ->
- install_service g root;
+ install_service g distro;
let t = Int64.of_float (Unix.time ()) in
let r = string_random8 () in
let filename = sprintf "%s/scripts/%Ld-%s-%s" firstboot_dir t r id in
--
1.7.12
12 years, 3 months
distro support in sysprep/firstboot.ml
by Olaf Hering
While hacking in sysprep/firstboot.ml, I wonder wether the current code
will work in anything but redhat-based distros. Is
/etc/rc.d/rc3.d/99something a script that would be executed in a Debian
based system for example?
Olaf
12 years, 3 months
[PATCH] sysprep: handle SuSE in hostname operation
by Olaf Hering
SuSE based installations store the hostname in /etc/HOSTNAME.
Add code to handle both opensuse and sles. Code to properly detect
the latter will be added with another patch.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index 3fc8800..363069b 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -45,6 +45,10 @@ let hostname_perform g root =
g#write filename file;
[ `Created_files ]
+ | "linux", ("opensuse"|"sles") ->
+ g#write "/etc/HOSTNAME" !hostname;
+ [ `Created_files ]
+
| "linux", ("debian"|"ubuntu") ->
g#write "/etc/hostname" !hostname;
[ `Created_files ]
--
1.7.12
12 years, 3 months
[PATCH] sysprep: handle suse-based in hostname operation
by Olaf Hering
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index 363069b..cbac46a 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -45,7 +45,7 @@ let hostname_perform g root =
g#write filename file;
[ `Created_files ]
- | "linux", ("opensuse"|"sles") ->
+ | "linux", ("opensuse"|"sles"|"suse-based") ->
g#write "/etc/HOSTNAME" !hostname;
[ `Created_files ]
--
1.7.12
12 years, 3 months
[PATCH] Update SuSE Linux detection.
by Olaf Hering
Update SuSE Linux detection. Up to now everything with a
/etc/SuSE-release file was treated as openSuSE. With this change SLES
based distributions such as "SUSE Linux Enterprise Server", "SUSE
Linux Enterprise Desktop" and "Novell Linux Desktop" will show up as
"sles". The 'opensuse' detection was updated to handle older openSuSE
releases as well as the well known SuSE Linux releases, starting from
6.0. Everything else with a /etc/SuSE-release file will show up as
"suse-based".
Here is a collection of release files:
==> Dist/6.0/etc/SuSE-release <==
SuSE Linux 6.0 (i386)
VERSION = 6.0
==> Dist/6.1/etc/SuSE-release <==
SuSE Linux 6.1 (i386)
VERSION = 6.1
==> Dist/6.2/etc/SuSE-release <==
SuSE Linux 6.2 (i386)
VERSION = 6.2
==> Dist/6.3/etc/SuSE-release <==
SuSE Linux 6.3 (i386)
VERSION = 6.3
==> Dist/6.4/etc/SuSE-release <==
SuSE Linux 6.4 (i386)
VERSION = 6.4
==> Dist/7.0/etc/SuSE-release <==
SuSE Linux 7.0 (i386)
VERSION = 7.0
==> Dist/7.1/etc/SuSE-release <==
SuSE Linux 7.1 (i386)
VERSION = 7.1
==> Dist/7.2/etc/SuSE-release <==
SuSE Linux 7.2 (i386)
VERSION = 7.2
==> Dist/7.3/etc/SuSE-release <==
SuSE Linux 7.3 (i386)
VERSION = 7.3
==> Dist/8.0/etc/SuSE-release <==
SuSE Linux 8.0 (i386)
VERSION = 8.0
==> Dist/8.1/etc/SuSE-release <==
SuSE Linux 8.1 (i386)
VERSION = 8.1
==> Dist/8.2/etc/SuSE-release <==
SuSE Linux 8.2 (x86-64)
VERSION = 8.2
==> Dist/9.0/etc/SuSE-release <==
SuSE Linux 9.0 (x86-64)
VERSION = 9.0
==> Dist/9.1/etc/SuSE-release <==
SuSE Linux 9.1 (x86-64)
VERSION = 9.1
==> Dist/9.2/etc/SuSE-release <==
SuSE Linux 9.2 (x86-64)
VERSION = 9.2
==> Dist/9.3/etc/SuSE-release <==
SuSE Linux 9.3 (x86-64)
VERSION = 9.3
==> Dist/10.0/etc/SuSE-release <==
SUSE LINUX 10.0 (X86-64) OSS
VERSION = 10.0
==> Dist/10.1-remastered/etc/SuSE-release <==
SUSE LINUX 10.1 (X86-64)
VERSION = 10.1
==> Dist/10.1/etc/SuSE-release <==
SUSE Linux 10.1 (X86-64) Beta8
VERSION = 10.1
==> Dist/10.2/etc/SuSE-release <==
openSUSE 10.2 (X86-64)
VERSION = 10.2
==> Dist/10.3/etc/SuSE-release <==
openSUSE 10.3 (X86-64)
VERSION = 10.3
==> Dist/11.0/etc/SuSE-release <==
openSUSE 11.0 (X86-64)
VERSION = 11.0
==> Dist/11.1/etc/SuSE-release <==
openSUSE 11.1 (x86_64)
VERSION = 11.1
==> Dist/11.2/etc/SuSE-release <==
openSUSE 11.2 (x86_64)
VERSION = 11.2
==> Dist/11.3/etc/SuSE-release <==
openSUSE 11.3 (x86_64)
VERSION = 11.3
==> Dist/11.4/etc/SuSE-release <==
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon
==> Dist/12.1/etc/SuSE-release <==
openSUSE 12.1 (x86_64)
VERSION = 12.1
CODENAME = Asparagus
==> Dist/12.2/etc/SuSE-release <==
openSUSE 12.2 (x86_64)
VERSION = 12.2
CODENAME = Mantis
==> Dist/sles8/etc/SuSE-release <==
SuSE SLES-8 (AMD64)
VERSION = 8.1
==> Dist/sles9/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
==> Dist/sles9sp2/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 2
==> Dist/sles9sp3/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 3
==> Dist/sles9sp4/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 4
==> Dist/sled10/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
==> Dist/sled10sp1/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 1
==> Dist/sled10sp2/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 2
==> Dist/sled10sp3/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 3
==> Dist/sled10sp4/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4
==> Dist/sled11/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0
==> Dist/sled11sp1/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1
==> Dist/sled11sp2/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
==> Dist/sles10/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
==> Dist/sles10sp1/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 1
==> Dist/sles10sp2/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 2
==> Dist/sles10sp3/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 3
==> Dist/sles10sp4/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4
==> Dist/sles11/etc/SuSE-release <==
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0
==> Dist/sles11sp1/etc/SuSE-release <==
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1
==> Dist/sles11sp2/etc/SuSE-release <==
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
generator/actions.ml | 8 ++++
src/guestfs-internal.h | 2 +
src/inspect-fs-unix.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++--
src/inspect-fs.c | 4 ++
src/inspect-icon.c | 2 +
src/inspect.c | 2 +
6 files changed, 114 insertions(+), 4 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index a17fed0..438b316 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -1000,6 +1000,14 @@ Scientific Linux.
Slackware.
+=item \"sles\"
+
+SuSE Linux Enterprise Server or Desktop.
+
+=item \"suse-based\"
+
+Some openSuSE-derived distro.
+
=item \"ttylinux\"
ttylinux.
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 8f2e26d..22f1623 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -346,6 +346,8 @@ enum inspect_os_distro {
OS_DISTRO_BUILDROOT,
OS_DISTRO_CIRROS,
OS_DISTRO_FREEDOS,
+ OS_DISTRO_SUSE_BASED,
+ OS_DISTRO_SLES,
};
enum inspect_os_package_format {
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index b8141d5..91b8516 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -67,6 +67,12 @@ static pcre *re_mdN;
static pcre *re_freebsd;
static pcre *re_diskbyid;
static pcre *re_netbsd;
+static pcre *re_opensuse;
+static pcre *re_sles;
+static pcre *re_nld;
+static pcre *re_opensuse_version;
+static pcre *re_sles_version;
+static pcre *re_sles_patchlevel;
static void compile_regexps (void) __attribute__((constructor));
static void free_regexps (void) __attribute__((destructor));
@@ -112,6 +118,12 @@ compile_regexps (void)
COMPILE (re_freebsd, "^/dev/ad(\\d+)s(\\d+)([a-z])$", 0);
COMPILE (re_diskbyid, "^/dev/disk/by-id/.*-part(\\d+)$", 0);
COMPILE (re_netbsd, "^NetBSD (\\d+)\\.(\\d+)", 0);
+ COMPILE (re_opensuse, "^(openSUSE|SuSE Linux|SUSE LINUX) ", 0);
+ COMPILE (re_sles, "^SUSE (Linux|LINUX) Enterprise ", 0);
+ COMPILE (re_nld, "^Novell Linux Desktop ", 0);
+ COMPILE (re_opensuse_version, "^VERSION = (\\d+)\\.(\\d+)", 0);
+ COMPILE (re_sles_version, "^VERSION = (\\d+)", 0);
+ COMPILE (re_sles_patchlevel, "^PATCHLEVEL = (\\d+)", 0);
}
static void
@@ -134,6 +146,12 @@ free_regexps (void)
pcre_free (re_freebsd);
pcre_free (re_diskbyid);
pcre_free (re_netbsd);
+ pcre_free (re_opensuse);
+ pcre_free (re_sles);
+ pcre_free (re_nld);
+ pcre_free (re_opensuse_version);
+ pcre_free (re_sles_version);
+ pcre_free (re_sles_patchlevel);
}
static void check_architecture (guestfs_h *g, struct inspect_fs *fs);
@@ -301,6 +319,82 @@ parse_lsb_release (guestfs_h *g, struct inspect_fs *fs)
return r ? 1 : 0;
}
+static int
+parse_suse_release (guestfs_h *g, struct inspect_fs *fs, const char *filename)
+{
+ int64_t size;
+ char *major, *minor;
+ char **lines;
+ int r = -1;
+
+ /* Don't trust guestfs_head_n not to break with very large files.
+ * Check the file size is something reasonable first.
+ */
+ size = guestfs_filesize (g, filename);
+ if (size == -1)
+ /* guestfs_filesize failed and has already set error in handle */
+ return -1;
+ if (size > MAX_SMALL_FILE_SIZE) {
+ error (g, _("size of %s is unreasonably large (%" PRIi64 " bytes)"),
+ filename, size);
+ return -1;
+ }
+
+ lines = guestfs_head_n (g, 10, filename);
+ if (lines == NULL)
+ return -1;
+
+ /* First line is dist release name */
+ fs->product_name = safe_strdup (g, lines[0]);
+ if (fs->product_name == NULL)
+ goto out;
+
+ /* Match SLES first because openSuSE regex overlaps some SLES release strings */
+ if (match (g, fs->product_name, re_sles) || match (g, fs->product_name, re_nld)) {
+ fs->distro = OS_DISTRO_SLES;
+
+ /* Second line contains version string */
+ if (lines[1] == NULL)
+ goto out;
+ major = match1 (g, lines[1], re_sles_version);
+ fs->major_version = guestfs___parse_unsigned_int (g, major);
+ free (major);
+ if (fs->major_version == -1)
+ goto out;
+
+ /* Third line contains service pack string */
+ if (lines[2] == NULL)
+ goto out;
+ minor = match1 (g, lines[2], re_sles_patchlevel);
+ fs->minor_version = guestfs___parse_unsigned_int (g, minor);
+ free (minor);
+ if (fs->minor_version == -1)
+ goto out;
+ }
+ else if (match (g, fs->product_name, re_opensuse)) {
+ fs->distro = OS_DISTRO_OPENSUSE;
+
+ /* Second line contains version string */
+ if (lines[1] == NULL)
+ goto out;
+ if (match2 (g, lines[1], re_opensuse_version, &major, &minor)) {
+ fs->major_version = guestfs___parse_unsigned_int (g, major);
+ fs->minor_version = guestfs___parse_unsigned_int (g, minor);
+ free (major);
+ free (minor);
+ if (fs->major_version == -1 || fs->minor_version == -1)
+ goto out;
+ }
+ }
+
+ r = 0;
+
+out:
+ guestfs___free_string_list (lines);
+
+ return r;
+}
+
/* The currently mounted device is known to be a Linux root. Try to
* determine from this the distro, version, etc. Also parse
* /etc/fstab to determine the arrangement of mountpoints and
@@ -464,13 +558,11 @@ guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs)
return -1;
}
else if (guestfs_exists (g, "/etc/SuSE-release") > 0) {
- fs->distro = OS_DISTRO_OPENSUSE;
+ fs->distro = OS_DISTRO_SUSE_BASED;
- if (parse_release_file (g, fs, "/etc/SuSE-release") == -1)
+ if (parse_suse_release (g, fs, "/etc/SuSE-release") == -1)
return -1;
- if (guestfs___parse_major_minor (g, fs) == -1)
- return -1;
}
/* Buildroot (http://buildroot.net) is an embedded Linux distro
* toolkit. It is used by specific distros such as Cirros.
diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index 7354029..2dbafb5 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -410,7 +410,9 @@ check_package_format (guestfs_h *g, struct inspect_fs *fs)
case OS_DISTRO_RHEL:
case OS_DISTRO_MAGEIA:
case OS_DISTRO_MANDRIVA:
+ case OS_DISTRO_SUSE_BASED:
case OS_DISTRO_OPENSUSE:
+ case OS_DISTRO_SLES:
case OS_DISTRO_CENTOS:
case OS_DISTRO_SCIENTIFIC_LINUX:
fs->package_format = OS_PACKAGE_FORMAT_RPM;
@@ -484,7 +486,9 @@ check_package_management (guestfs_h *g, struct inspect_fs *fs)
fs->package_management = OS_PACKAGE_MANAGEMENT_URPMI;
break;
+ case OS_DISTRO_SUSE_BASED:
case OS_DISTRO_OPENSUSE:
+ case OS_DISTRO_SLES:
fs->package_management = OS_PACKAGE_MANAGEMENT_ZYPPER;
break;
diff --git a/src/inspect-icon.c b/src/inspect-icon.c
index 19acfb9..531ba61 100644
--- a/src/inspect-icon.c
+++ b/src/inspect-icon.c
@@ -152,7 +152,9 @@ guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r,
r = icon_mageia (g, fs, &size);
break;
+ case OS_DISTRO_SUSE_BASED:
case OS_DISTRO_OPENSUSE:
+ case OS_DISTRO_SLES:
r = icon_opensuse (g, fs, &size);
break;
diff --git a/src/inspect.c b/src/inspect.c
index 5dd9266..f16aea1 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -232,6 +232,8 @@ guestfs__inspect_get_distro (guestfs_h *g, const char *root)
case OS_DISTRO_RHEL: ret = safe_strdup (g, "rhel"); break;
case OS_DISTRO_SCIENTIFIC_LINUX: ret = safe_strdup (g, "scientificlinux"); break;
case OS_DISTRO_SLACKWARE: ret = safe_strdup (g, "slackware"); break;
+ case OS_DISTRO_SLES: ret = safe_strdup (g, "sles"); break;
+ case OS_DISTRO_SUSE_BASED: ret = safe_strdup (g, "suse-based"); break;
case OS_DISTRO_TTYLINUX: ret = safe_strdup (g, "ttylinux"); break;
case OS_DISTRO_WINDOWS: ret = safe_strdup (g, "windows"); break;
case OS_DISTRO_UBUNTU: ret = safe_strdup (g, "ubuntu"); break;
--
1.7.12
12 years, 3 months