53 Commits

Author SHA1 Message Date
Richard W.M. Jones
72cfaff5c5 Update copyright dates for 2025
Automated using this command:

perl -pi.bak -e 's/(20[012][0-9])-20[12][01234]/$1-2025/g' `git ls-files`
2025-02-16 17:00:46 +00:00
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
Laszlo Ersek
0ab9305055 daemon/mkfs: disable creation of fake MBR partition table with "mkfs.fat"
Search the usage output of "mkfs.fat" for "--mbr[="; cache the result for
further invocations. If the option is supported, pass "--mbr=n" to
"mkfs.fat". This will prevent the creation of a bogus partition table
whose first (and only) entry describes a partition that contains the
partition table.

(Such a bogus partition table breaks "parted", which is a tool used by
libguestfs extensively, both internally and in public libguestfs APIs.)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1931821
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-2-lersek@redhat.com>
2021-11-26 10:16:05 +01:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
381c8b68c4 daemon: Remove GUESTFSD_EXT_CMD.
GUESTFSD_EXT_CMD was used by OpenSUSE to track which external commands
are run by the daemon and package those commands into the appliance.

It is no longer used by recent SUSE builds, so remove it.

Thanks: Pino Toscano, Olaf Hering.
2017-07-27 17:31:41 +01:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Richard W.M. Jones
d5a8f82887 Use 'const' for stack integers where possible.
May improve optimization possibilities in a few cases.
2016-07-26 10:43:45 +01:00
Pino Toscano
08a7c5c47b daemon: mkfs: allow setting labels for f2fs filesystems
Pass -L $LABEL to set the label of a f2fs filesystem when creating it.
2016-07-20 10:17:04 +02:00
Richard W.M. Jones
1007b2555c daemon: Fix ext2 labels error message (RHBZ#1294956). 2016-01-04 15:33:45 +00:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
120b658ccc Avoid various "declaration of <var> shadows a previous local"
I enabled the -Wshadow warning temporarily in order to do these fixes,
but had to disable it again afterwards.  The reason is that this warns
about shadowing globals, which is sort of a good thing, but because we
have a global called "verbose" just about everywhere, and at the same
time we baked a function argument called "verbose" into several
unchangable APIs, well, we're stuck without being able to use this
warning.
2015-11-13 11:53:12 +00:00
Chen Hanxiao
d29337605a daemon: add a space after func/macro to fit code-style
more daemon codes covered

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-07-17 13:27:13 +01:00
Pino Toscano
7723614a91 mkfs: add 'label' optional argument
Add the 'label' optional argument to the mkfs action, so it is possible
to set a filesystem label direct when creating it. There may be
filesystems not supporting changing the label of existing filesystems
but only setting it at creation time, so this new optarg will help.

Implement it for the most common filesystems (ext*, fat, ntfs, btrfs,
xfs), giving an error for all the others, just like set_label does.
2015-01-19 16:47:53 +01:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
40512c66af daemon: Always pass -F option to mkfs.ntfs.
Otherwise it moans about:

  mkfs: ntfs: /dev/sda: /dev/sda is entire device, not just one partition.
  Refusing to make a filesystem here!

This has been happening for a while, so I don't know why we didn't
notice it before.  It even happens on RHEL 6.

A simple reproducer is:

  virt-make-fs -t ntfs any-tarball.tar.gz test.img
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
b121015221 daemon: mkfs: Use -I option to force mkfs.fat to write a filesystem over a whole device (RHBZ#1039995).
If you use virt-make-fs to create a partitionless FAT-formatted disk
image then currently you will get an error:

$ virt-make-fs --type=fat . /tmp/test.img
'mkfs' (create filesystem) operation failed.
Instead of 'fat', try 'vfat' (long filenames) or 'msdos' (short filenames).
mkfs: fat: /dev/sda: mkfs.fat: Device partition expected, not making filesystem on entire device '/dev/sda' (use -I to override) at /usr/bin/virt-make-fs line 508, <PIPE> line 1.
      ...propagated at /usr/bin/virt-make-fs line 518, <PIPE> line 1.

With this patch, the error goes away and partitionless disks can be
created.
2013-12-10 13:46:54 +00:00
Richard W.M. Jones
3201e75564 mkfs: Use -b size=<size> for xfs (RHBZ#981715). 2013-07-18 14:36:25 +01:00
Richard W.M. Jones
fb0bd82dbe daemon: Verify ext2/3/4 filesystem name before passing to mke2fs (RHBZ#978302).
Add a utility function (fstype_is_extfs) to match ext2/3/4 filesystem
names.  This is used in a couple of places.

When passing the mke2fs -t parameter, verify that the request is for
an ext2/3/4 filesystem.  Previously we did not check this, and neither
did mke2fs when the -F flag was also used.
2013-06-26 14:37:26 +01:00
Richard W.M. Jones
72dd398679 daemon: Call wipefs before mkfs to work around pathological behaviour in btrfs.
See: RHBZ#907554, http://www.spinics.net/lists/linux-btrfs/msg21197.html
2013-02-04 21:54:15 +00:00
Richard W.M. Jones
0d18a8b407 Update copyright dates for 2013. 2013-02-02 13:56:19 +00:00
Richard W.M. Jones
950951c67d daemon: Use the new CLEANUP_* macros to simplify code. 2013-01-28 18:01:43 +00:00
Richard W.M. Jones
7376811983 Revert "btrfs: Add a workaround for btrfs failures seen with kernel 3.7.0."
Revert "btrfs: Add an extended workaround for btrfs failures seen with kernel 3.7.0."

Reverted these workaround, since we may have found a fix for the btrfs
bug itself (for details see RHBZ#863978).

This reverts commit d9e5b514aa
and commit a03f536f0d.
2012-10-10 18:26:18 +01:00
Richard W.M. Jones
d9e5b514aa btrfs: Add a workaround for btrfs failures seen with kernel 3.7.0.
See:
https://bugzilla.redhat.com/show_bug.cgi?id=863978
and:
http://thread.gmane.org/gmane.comp.file-systems.btrfs/20257
2012-10-09 11:09:17 +01:00
Richard W.M. Jones
d6bb49a172 syntax: Remove include <dirent.h> in files that don't use it.
Found by 'make syntax-check'.
2012-09-15 12:35:59 +01:00
Olaf Hering
0306c98d31 daemon: collect list of called external commands
guestfsd calls many different tools. Keeping track of all of them is
error prone. This patch introduces a new helper macro to put the command
string into its own ELF section:

GUESTFSD_EXT_CMD(C_variable, command_name);

This syntax makes it still possible to grep for used command names.

The actual usage of the collected list could be like this:

  objcopy -j .guestfsd_ext_cmds -O binary daemon/guestfsd /dev/stdout |
  tr '\0' '\n' | sort -u

The resulting output will be used to tell mkinitrd which programs to
copy into the initrd.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

RWMJ:
 - Move str_vgchange at request of author.
 - Fix snprintf call in daemon/debug.c
2012-08-30 20:57:07 +01:00
Richard W.M. Jones
163e030ee1 daemon: Remove e2prog hack (only needed for RHEL 5).
Instead this patch will be carried out of tree in the oldlinux branch.
2012-08-30 17:29:36 +01:00
Richard W.M. Jones
e055bf4cab generator: Rename 'mkfs_opts' API to 'mkfs'.
By using the once_had_no_optargs flag, this change is backwards
compatible for callers.
2012-07-14 12:43:13 +01:00
Richard W.M. Jones
50009403b3 New API: mkfs-btrfs for creating btrfs filesystems (RHBZ#807905).
This allows all parameters from btrfs to be accessed.
2012-04-02 10:12:38 +01:00
Richard W.M. Jones
77ac6b73cd mkfs: Don't allow blocksize to be set on btrfs (RHBZ#807905). 2012-04-02 08:46:23 +01:00
Richard W.M. Jones
08840bab44 Tempus fugit.
Update all copyright dates to 2012.
2012-01-18 22:05:02 +00:00
Wanlong Gao
2ac869bcc8 mkfs: optimization and code cleanup
v1->v2: fix a typo pointed by Matt

Optimizations by reducing the STREQ operations and do some
code cleanup.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ: Whitespace changes.
2011-12-23 08:19:47 +00:00
Wanlong Gao
1970a14178 mkfs: enable to make xfs filesystems when the device already has a filesystem
Just add the -f option to mkfs.xfs to make sure we can
make a xfs filesystem when the device already has a
filesystem on it.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2011-12-02 14:01:28 +00:00
Richard W.M. Jones
edd502543a daemon: Define safe ADD_ARG macro for constructing arg lists on the stack. 2011-11-11 10:48:16 +00:00
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Richard W.M. Jones
c6340f4500 mkfs: Don't die if mke2fs is not available.
Allow other types of filesystems to be created.
2011-07-14 11:28:05 +01:00
Nikita A Menkovich
39d5c63be6 mkfs-opts: Add optional sectorsize parameter. 2011-07-06 10:52:04 +01:00
Nikita A Menkovich
24fb2c1255 Implement inode option to mkfs_opts command.
This is needed because older versions of grub(for example in centos)
do not understand filesystems created with newer version of e2fsprogs.
By default in e2fsprogs 1.4+ creates partitions with 256 bit inode
size, and grub expect 128 bit size.
2011-07-04 10:35:56 +01:00
Richard W.M. Jones
a0e3b21837 RHEL 5: Use mke4fs on RHEL 5 as replacement for mke2fs. 2011-03-25 14:42:40 +00:00
Richard W.M. Jones
227bea6c7e mkfs: Force mke2fs to create a filesystem even on raw IDE device (RHBZ#690819). 2011-03-25 14:34:31 +00:00
Nikita A Menkovich
92b74729e2 mkfs-opts: Add optional "features" parameter.
This allows the -O parameter to be added to the mkfs command line.
This is used to select filesystem features.
2011-01-26 15:34:01 +00:00
Richard W.M. Jones
d72815578f Remove several unused local variables.
(Revealed by compiling under Debian where this is a warning).
2010-12-10 12:19:49 +00:00
Richard W.M. Jones
0710326ac5 New API: mkfs_opts, mkfs with optional arguments.
This is an extensible version of 'mkfs' which supports optional
arguments.  There is now no need for 'mkfs_b' since you should
use 'mkfs_opts' with the optional 'blocksize' argument instead.
2010-12-02 13:43:18 +00:00
Richard Jones
4d5c228002 mkfs-b: Map block size to cluster size for VFAT and NTFS partitions (RHBZ#599464).
This also adds a regression test for VFAT and (conditionally)
NTFS filesystems.
2010-06-03 14:33:59 +01:00
Richard Jones
0606cb5467 mkfs-b: Check that blocksize parameter is > 0 and a power of 2. 2010-06-03 14:33:59 +01:00
Richard Jones
9e0b31a2af appliance: Set $PATH instead of hard-coding paths to binaries everywhere.
Change the appliance so PATH includes common directories.  Thus
we don't need to hard-code paths to binaries (eg. "/sbin/fdisk")
everywhere.
2010-03-26 13:36:30 +00:00
Richard Jones
e9c3711310 daemon: Don't need to prefix error messages with the command name.
The RPC stubs already prefix the command name to error messages.
The daemon doesn't have to do this.  As a (small) benefit this also
makes the daemon slightly smaller.

Code in the daemon such as:

  if (argv[0] == NULL) {
    reply_with_error ("passed an empty list");
    return NULL;
  }

now results in error messages like this:

  ><fs> command ""
  libguestfs: error: command: passed an empty list

(whereas previously you would have seen ..command: command:..)
2010-02-12 16:49:00 +00:00
Jim Meyering
9a8889e4d0 use STREQ, not strcmp: part 1
git grep -l 'strcmp *([^=]*== *0'|xargs \
  perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
2009-11-09 22:34:16 +01:00