summaryrefslogtreecommitdiffstats
path: root/daemon/mount.c
Commit message (Collapse)AuthorAgeFilesLines
* daemon: Reimplement 'mounts' and 'mountpoints' commands.Richard W.M. Jones2011-04-051-48/+29
| | | | | | | | Reimplement these so they read /proc/mounts instead of trying to parse the output of the 'mount' external command. One consequence of this is that these commands now work again for ntfs-3g filesystems.
* umount-all: Use /proc/mounts instead of output of 'mount' command.Richard W.M. Jones2011-03-221-34/+24
| | | | | | | | | | The particular issue is that ntfs-3g (or FUSE?) no longer appears to update /etc/mtab, which meant that umount-all was not unmounting these partitions. But parsing /proc/mounts is simpler and more robust in any case. Notes: Labels: bugfix
* proto: Fix FileIn ops that abort during the chunk upload stage.Richard W.M. Jones2011-03-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a previous, incorrect attempt to fix RHBZ#576879 we tried to prevent the daemon from sending an error reply if the daemon had cancelled the transfer. This is wrong: the daemon should send an error reply in these cases. A simple test case is this: guestfish -N fs -m /dev/sda1 upload big-file / (This fails because the target "/" is a directory, not a file.) Prior to this commit, libguestfs would hang instead of printing an error. With this commit, libguestfs prints an error. What is happening is: (1) Library is uploading a file (2) In the middle of the long upload, daemon detects an error. Daemon cancels. (3) Library detects cancel, sends cancel chunk, then waits for the error reply from the daemon. (4) Daemon is supposed to send an error reply message. Because step (4) wasn't happening, uploads that failed like this would hang in the library (waiting for the error message, while the daemon was waiting for the next request). This also adds a regression test. This temporarily breaks the "both ends cancel" case (RHBZ#576879c5). Therefore the test for that is disabled, and this is fixed in the next patch in the series. This partially reverts commit dc706a639eec16084c0618baf7bfde00c6565f63.
* daemon: Parse /proc/mounts instead of /etc/mtabRichard W.M. Jones2011-02-031-2/+5
| | | | | | | | | | | | | | | | | | | | | | | Since Fedora util-linux 2.19, the %post script does: rm -f /etc/mtab ln -s /proc/mounts /etc/mtab We are no longer running %post scripts, so this means that /etc/mtab is a plain file in the appliance. Usual 'mount' still updates it, but for some reason mount.ntfs does *not* update it in Fedora 15, meaning that you couldn't mount and then operate on NTFS partitions. It seems better to always parse /proc/mounts (ie. what the kernel thinks is mounted) unconditionally, rather than relying on the capriciousness of the external mount command. Therefore, parse /proc/mounts instead of /etc/mtab, but add a note saying that in future we should really be parsing /proc/self/mountinfo, but that needs a custom parser, and the format is rather tricky: http://lxr.linux.no/#linux+v2.6.37/Documentation/filesystems/proc.txt#L1462
* daemon: Replace root_mounted global with intelligence.Richard W.M. Jones2011-01-271-25/+49
| | | | | | | | | | | | | | | | | We used to maintain a global flag 'root_mounted' which tells us if the user has mounted something on root (ie. on the sysroot directory). This flag caused a lot of trouble (eg. RHBZ#599503) because it's hard to keep the flag updated correctly when the user can do arbitrary mounts and also use mkmountpoint. Remove this flag and replace it with a test to see if something is mounted on *or under* the sysroot. (It has to be *or under* because of mkmountpoint and friends). This also replaces a rather convoluted "have we mounted root yet" check in the mount* APIs with a simpler check to see if the mountpoint exists and is an ordinary directory.
* Revert "umount-all: Add udev_settle after unmounting disks."Richard W.M. Jones2010-12-071-3/+0
| | | | | | | This reverts commit ad2abf89c364d5ec73fb12af63b053637d99d757. Ubuntu still has errors even with the addition of udev_settle after umount-all. Therefore this was just masking the problem.
* umount-all: Add udev_settle after unmounting disks.Richard W.M. Jones2010-12-071-0/+3
| | | | | | This helps avoid an error on Ubuntu, but it's not clear if this is a real solution or just helps by adjusting the timing of some race condition.
* daemon: Fix /dev/mapper paths from mounts and mountpoints (RHBZ#646432).Richard W.M. Jones2010-10-281-0/+21
| | | | Make the LV paths returned by these two commands canonical.
* Fix FileIn cmds losing synch if both ends send cancel messages (RHBZ#576879).Richard Jones2010-05-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | During a FileIn command (eg. upload, tar-in) if both sides experience errors, then both sides could send cancel messages, the result being lost synchronization. The reason for the lost synch was because the daemon was ignoring this case and sending an error message back which the library side (which had cancelled) was not expecting. Fix this by checking in the daemon for the case where the library also cancels during daemon cancellation, and not sending an error messages. This also includes an enhanced regression test which checks for this case. This extends the original fix in commit 5922d7084d6b43f0a1a15b664c7082dfeaf584d0. More details can be found here: https://bugzilla.redhat.com/show_bug.cgi?id=576879#c5
* Fix upload losing synchronization if root not mounted (RHBZ#576879).Richard Jones2010-04-171-4/+4
| | | | | | | | | | | | Modify the generator so that it can correctly handle early cancellation for Pathname|Device|.. parameters. This fixes the upload command, but consequently we need to fix the parameters for tar_in and t?z_in commands. This should also mean that 'win:' can now be used as the second argument of tar_in and t?z_in commands in guestfish, whereas previously this wouldn't have worked. Adds a regression test for the original problem.
* daemon: Don't need to prefix error messages with the command name.Richard Jones2010-02-121-6/+6
| | | | | | | | | | | | | | | | | | | | 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:..)
* use STREQ, not strcmp: part 1Jim Meyering2009-11-091-1/+1
| | | | | git grep -l 'strcmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
* change strncmp() == 0 to STREQLEN()Jim Meyering2009-11-091-1/+1
| | | | | git grep -l 'strncmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *== *0\b/STREQLEN$1/g'
* umount: Enable device name translation for device parameter.Richard Jones2009-08-131-3/+8
|
* mount: Check mountpoints are absolute paths.Richard Jones2009-08-131-0/+2
|
* In rmmountpoint, have to explicitly check for ABS_PATH (*not* NEED_ROOT).Richard Jones2009-08-131-0/+3
|
* do_umount: don't use RESOLVE_DEVICE anymoreJim Meyering2009-08-131-13/+9
| | | | | * daemon/mount.c (do_umount): Don't use RESOLVE_DEVICE here, now that the caller always invokes REQUIRE_ROOT_OR_RESOLVE_DEVICE.
* generator.ml: use new "Pathname" designationJim Meyering2009-08-131-16/+10
| | | | | | | | | | 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.
* update all NEED_ROOT usesJim Meyering2009-08-131-3/+3
| | | | | | run this command: git grep -l -w NEED_ROOT|xargs perl -pi -e \ 's/(NEED_ROOT) \((.*?)\)/$1 (return $2)/'
* * src/generator.ml: Change all `String "device"' to `Device "device"'.Jim Meyering2009-08-131-2/+0
| | | | | | | | | | | | | | | | | | | | | 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.
* update all uses of ABS_PATHJim Meyering2009-08-131-3/+3
| | | | | | run this command: git grep -l -w ABS_PATH|xargs perl -pi -e \ 's/(?:ABS_PATH)( \(.*?,) (.*?)\)/ABS_PATH$1 return $2)/'
* change almost all uses: s/IS_DEVICE/RESOLVE_DEVICE/Jim Meyering2009-08-131-2/+2
| | | | | | Use this command: git grep -l -w IS_DEVICE|xargs perl -pi -e \ 's/\b(?:IS_DEVICE)\b( \(.*?,) (.*?)\)/RESOLVE_DEVICE$1 return $2)/'
* Convert all TABs-as-indentation to spaces.Jim Meyering2009-08-031-20/+20
| | | | | | | | | | | 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 : $_'
* Make /sysroot path configurable.Richard Jones2009-07-181-27/+23
| | | | | | | | | Currently /sysroot is hard-coded throughout the daemon code. This patch turns the path into a variable so that we can change it in future, for example to allow standalone mode to be implemented. This patch was tested by running all the C API tests successfully.
* New commands: 'mkmountpoint' and 'rmmountpoint'Richard W.M. Jones2009-07-151-0/+51
| | | | | | | | | | | | | | | | | | | | | These specialized commands are used to create additional mountpoints before mounting filesystems. They are only used where you want to mount several unrelated or read-only filesystems together, and need additional care to use correctly. Here is how to use these calls to unpack the "Russian doll" nest of a Fedora 11 live CD: add-ro Fedora-11-i686-Live.iso run mkmountpoint /cd mkmountpoint /squash mkmountpoint /ext3 mount /dev/sda /cd mount-loop /cd/LiveOS/squashfs.img /squash mount-loop /squash/LiveOS/ext3fs.img /ext3 The inner filesystem is now unpacked under the /ext3 mountpoint.
* New command: 'mountpoints' which returns a hash of device -> mountpoint.Richard W.M. Jones2009-07-151-2/+29
|
* remove trailing blanksJim Meyering2009-07-031-1/+1
|
* Add mount-loop command (RHBZ#508668).Richard W.M. Jones2009-06-291-0/+44
| | | | | | | | | Loop device mounts don't work for the generic 'mount' commands because the first parameter should be a file not a device. We want to separate out files parameters from device parameters in the long term, so this adds a new mount-loop command for this purpose.
* Fix memory leak in daemon/mount.c:do_mount_vfs.Richard W.M. Jones2009-06-291-0/+1
|
* In the daemon, change all const char * parameters to char *.Richard Jones2009-06-101-7/+7
|
* Add IS_DEVICE checks for all calls which take a device parameter.Richard Jones2009-06-101-3/+6
|
* Fix umount_all command so it unmounts filesystems in the correct order.Richard Jones2009-04-301-8/+68
|
* Add mount_ro, mount_options, mount_vfs. Fix small bug in OCaml generator.Richard Jones2009-04-221-4/+29
|
* Added test suite.Richard Jones2009-04-111-0/+115
|
* Implemented 'mount' and 'touch' commands.Richard Jones2009-04-031-0/+76