26 Commits

Author SHA1 Message Date
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
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
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
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Richard W.M. Jones
b9bd24b943 daemon: In sfdisk call blockdev --rereadpt with device name. 2010-11-23 18:42:26 +00:00
Richard W.M. Jones
1937698c25 daemon: Tolerate failure of blockdev --rereadpt after sfdisk.
See commit 840536ea5a
and commit 956fc5a3fe.
2010-11-02 20:33:06 +00:00
Richard W.M. Jones
840536ea5a Call blockdev --rereadpt then udev_settle after sfdisk commands.
This updates commit 956fc5a3fe so
that we call udev_settle after rereading the partition table.  This
ensures that the devices nodes for the new partitions have been
created.
2010-09-24 19:11:56 +01:00
Richard W.M. Jones
956fc5a3fe Call blockdev --rereadpt after sfdisk commands.
On fast machines sfdisk has some sort of race where it
fails to re-read the partition table it has just created
(it's not clear if this is a race in sfdisk, the kernel or
some other component).

This commit works around the problem by calling
blockdev --rereadpt after sfdisk operations, which
experience shows is enough to stop the problem from
happening.
2010-09-22 16:35:52 +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
9b0ab84185 sfdisk.c, fallocate.c: use a string literal as format
* daemon/fallocate.c (do_fallocate): Format was not a string literal.
* daemon/sfdisk.c (sfdisk): Likewise.
2009-08-17 11:40:24 +02:00
Jim Meyering
adf20c0c4d adjust const "**" pointers to avoid warnings
Also, ...
* src/generator.ml: Add DeviceList type, and propagate that change
out to all calling/interface code.
2009-08-17 11:40:24 +02:00
Jim Meyering
bd34e4e942 sfdisk: guard against buffer overflow
* daemon/sfdisk.c (sfdisk): Don't let outrageous "extra_flag"
or "device" strings overflow a fixed-size buffer.
2009-08-13 14:45:34 +02:00
Jim Meyering
84fc760439 generator.ml: use new "Pathname" designation
Nearly every file-related function in daemons/*.c is affected:
Remove this pair of statements from each affected do_* function:
-  NEED_ROOT (return -1);
-  ABS_PATH (dir, return -1);
and change the type of the corresponding parameter to "const char *".
* src/generator.ml: Emit NEED_ROOT just once, even when there are two or
more Pathname args.
2009-08-13 14:45:34 +02:00
Jim Meyering
0c07f0d236 * src/generator.ml: Change all String "device"' to Device "device"'.
Then update each affected function, removing each uses of RESOLVE_DEVICE,
now that it's generated in caller from stub.c.
* daemon/blockdev.c (call_blockdev): Remove use of RESOLVE_DEVICE.
* daemon/devsparts.c (do_mkfs): Likewise.
* daemon/ext2.c (do_e2fsck_f, do_get_e2label, do_get_e2uuid): Likewise.
(do_resize2fs, do_set_e2label, do_set_e2uuid, do_tune2fs_l): Likewise.
* daemon/fsck.c (do_fsck): Likewise.
* daemon/grub.c (do_grub_install): Likewise.
* daemon/lvm.c (do_lvremove, do_pvcreate, do_pvremove): Likewise.
(do_pvresize): Likewise.
* daemon/mount.c (do_mount_vfs): Likewise.
* daemon/ntfs.c (do_ntfs_3g_probe): Likewise.
* daemon/scrub.c (do_scrub_device): Likewise.
* daemon/sfdisk.c (sfdisk, sfdisk_flag): Likewise.
* daemon/swap.c (do_mkswap, do_mkswap_L, do_mkswap_U): Likewise.
(do_swapoff_device, do_swapon_device): Likewise.
* daemon/zero.c (do_zero): Likewise.
* daemon/zerofree.c (do_zerofree): Likewise.
2009-08-13 14:45:34 +02:00
Jim Meyering
e8795f3e9c convert the last few, manually 2009-08-13 14:45:33 +02:00
Jim Meyering
1997858e90 change almost all uses: s/IS_DEVICE/RESOLVE_DEVICE/
Use this command:
  git grep -l -w IS_DEVICE|xargs perl -pi -e \
    's/\b(?:IS_DEVICE)\b( \(.*?,) (.*?)\)/RESOLVE_DEVICE$1 return $2)/'
2009-08-13 14:45:33 +02:00
Jim Meyering
2f1a50d816 Convert all TABs-as-indentation to spaces.
Do it by running this command:
[exempted files are matched via .x-sc_TAB_in_indentation]

  git ls-files \
    | pcregrep -vf .x-sc_TAB_in_indentation \
    | xargs pcregrep -l '^ *\t' \
    | xargs perl -MText::Tabs -ni -le \
      '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
2009-08-03 17:17:57 +02:00
Jim Meyering
a7b73d4a1e remove trailing blanks 2009-07-03 17:04:21 +02:00
Richard W.M. Jones
b2c76a898b Add 'sfdiskM' command.
This command is a saner interface to partitioning.

All partition sizes are specified in megabytes (not cylinders).
You don't need to specify the cyls/heads/secs parameters.

All the test code has been updated to use this, so it is now
CHS-independent (eg. when CHS changes as between IDE and virtio).
2009-07-02 21:50:30 +01:00
Richard W.M. Jones
99e28249d5 Call 'udevadm settle' after operations which add/remove device nodes.
Because udev operates asynchronously, we found errors which were
caused by a previous command (eg. sfdisk or pvremove) creating
or removing a device, and that change not having happened by the
time the next command was run.

This patch adds calls to '/sbin/udevadm settle' after any commands
which can add or remove device nodes.

If udev is not being used or not available, this should have no
effect.  The command fails and this is silently ignored.
2009-07-01 17:15:24 +01:00
Richard W.M. Jones
fe27753ae5 Fix error handling of external sfdisk command.
Should use 'pclose' instead of 'fclose' (although fclose happens
to work because of glibc internals).

The result of pclose is the exit status of the command, so we
need to test this is != 0.
2009-07-01 16:36:13 +01:00
Richard Jones
56bef498f4 In the daemon, change all const char * parameters to char *. 2009-06-10 14:16:47 +01:00
Richard Jones
85ed8cef99 Add vg-activate{,-all} commands, and resize recipe. 2009-05-18 17:16:24 +01:00
Richard W.M. Jones
5cd39c83e2 Add: pvresize, sfdisk-N, sfdisk-l, sfdisk-kernel-geomtry, sfdisk-disk-geometry commands. Pass --no-reread flag to sfdisk. 2009-05-15 14:52:34 +01:00