summaryrefslogtreecommitdiffstats
path: root/daemon/devsparts.c
Commit message (Collapse)AuthorAgeFilesLines
* launch: Add add_drive 'label' option.Richard W.M. Jones2012-10-081-0/+76
| | | | | | | | | | | | | | | | | | | | | New API: list-disk-labels Allow the user to pass an optional disk label when adding a drive. This is passed through to qemu / libvirt using the disk serial field, and from there to the appliance which exposes it through udev, creating a special alias of the device /dev/disk/guestfs/<label>. Partitions are named /dev/disk/guestfs/<label><partnum>. virtio-blk and virtio-scsi limit the serial field to 20 bytes. We further limit the name to maximum 20 ASCII characters in [a-zA-Z]. list-devices and list-partitions are not changed: these calls still return raw block device names. However a new call, list-disk-labels, returns a hash table allowing callers to map between disk labels, and block device and partition names. This commit also includes a test.
* daemon: Code tidy up in devsparts.Richard W.M. Jones2012-07-021-8/+9
| | | | No functional change.
* New API: guestfs_nr_devicesRichard W.M. Jones2012-06-291-0/+17
| | | | | | This returns the number of whole block devices added. It is usually simpler to call this than to list the devices and count them, which is what we do in some places in the current codebase.
* New API: device-index.Richard W.M. Jones2012-06-131-0/+23
| | | | | | This returns the index of the device, eg. /dev/sdb => 1. Or you can think of it as the order that the device was added, or the index of the device in guestfs_list_devices.
* daemon: Fix order of devices in guestfs_list_devices when > 26 disks.Richard W.M. Jones2012-06-131-2/+2
| | | | | Sort the device names correctly, not just treating them as strings. As a result, /dev/sdz < /dev/sdaa.
* Use O_CLOEXEC / SOCK_CLOEXEC for almost all file descriptors.Richard W.M. Jones2012-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The presumption is that all file descriptors should be created with the close-on-exec flag set. The only exception are file descriptors that we want passed through to exec'd subprocesses (mainly pipes and stdin/stdout/stderr). For open calls, we pass O_CLOEXEC as an extra flag, eg: fd = open ("foo", O_RDONLY|O_CLOEXEC); This is a Linux-ism, but using a macro we can easily make it portable. For sockets, similarly: sock = socket (..., SOCK_STREAM|SOCK_CLOEXEC, ...); For accepted sockets, we use the Linux accept4 system call which allows flags to be supplied, but we use the Gnulib 'accept4' module to make this portable. For dup, dup2, we use the Linux dup3 system call, and the Gnulib modules 'dup3' and 'cloexec'.
* daemon: Implement a growable strings buffer type.Richard W.M. Jones2012-03-131-27/+23
| | | | | | | | | | | | | | | | | | | | | | | | Previously a lot of daemon code used three variables (a string list, 'int size' and 'int alloc') to track growable strings buffers. This commit implements a simple struct containing the same variables, but using size_t instead of int: struct stringsbuf { char **argv; size_t size; size_t alloc; }; Use it like this: DECLARE_STRINGSBUF (ret); //... if (add_string (&ret, str) == -1) return NULL; //... if (end_stringsbuf (&ret) == -1) return NULL; return ret.argv;
* Update FSF address.Matthew Booth2011-11-081-1/+1
|
* New API: part-to-partnumRichard W.M. Jones2011-10-251-0/+25
| | | | | | This converts a partition device name (eg. /dev/sda1) to a partition number (eg. 1). This is useful in conjunction with the parted APIs that mostly take a disk device + partnum.
* Coverity: Close directory handle along error paths.Richard W.M. Jones2011-06-091-0/+2
|
* Coverity: Avoid calling sort_strings (NULL, 0) on empty list.Richard W.M. Jones2011-06-091-2/+3
|
* New API: part-to-dev: Convert partition name to device name.Richard Jones2010-09-151-0/+27
| | | | | This adds a formal API for going from a partition to the containing device, eg. /dev/sda1 -> /dev/sda
* Change to using ext2-based, cached supermin appliance.Richard Jones2010-08-231-0/+4
| | | | | | | | | | | | This changes the method used to build the supermin appliance to use the new ext2-based appliance supported by latest febootstrap. The appliance can also be cached, so we avoid rebuilding it each time it is used. Mailing list discussion goes into the rationale and details: https://www.redhat.com/archives/libguestfs/2010-August/msg00028.html Requires febootstrap >= 2.8.
* change strncmp() == 0 to STREQLEN()Jim Meyering2009-11-091-5/+5
| | | | | git grep -l 'strncmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *== *0\b/STREQLEN$1/g'
* New commands: mkfs-b, mke2journal*, mke2fs-J*Richard W.M. Jones2009-08-151-17/+0
| | | | | | | | | | mkfs-b: Pass the -b (blocksize) parameter to mkfs. mke2journal and friends: Lets you create external ext2 journals on devices. mke2fs-J and friends: Lets you create ext2/3/4 filesystems with external journals.
* generator.ml: use new "Pathname" designationJim Meyering2009-08-131-1/+1
| | | | | | | | | | 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.
* * 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.
* change almost all uses: s/IS_DEVICE/RESOLVE_DEVICE/Jim Meyering2009-08-131-1/+1
| | | | | | Use this command: git grep -l -w IS_DEVICE|xargs perl -pi -e \ 's/\b(?:IS_DEVICE)\b( \(.*?,) (.*?)\)/RESOLVE_DEVICE$1 return $2)/'
* Fix errno check in readdir in devsparts.cMatthew Booth2009-08-061-3/+5
|
* Recognise cd-rom devices in devsparts.cMatthew Booth2009-08-061-72/+96
| | | | | | Also: * Un-duplicate device detection code by creating a common mapping function. * Add some more comments.
* Convert all TABs-as-indentation to spaces.Jim Meyering2009-08-031-25/+25
| | | | | | | | | | | 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 : $_'
* fix comments; move declarationsJim Meyering2009-07-301-6/+4
| | | | | | * daemon/devsparts.c (do_list_devices, do_list_partitions): Remove stray words in comments. Move declarations down to definition.
* Don't show empty CD devices (RHBZ#514505).Richard Jones2009-07-291-0/+27
|
* remove trailing blanksJim Meyering2009-07-031-1/+1
|
* Change to use virtio_blk (virtio block device) by default.Richard W.M. Jones2009-07-011-2/+4
| | | | | | | | | | | | | virtio_blk is the fast, virt-native block device driver supported by qemu and KVM. Note that virtio_blk device names are called /dev/vd*. Existing scripts should continue working because device name translation will silently change device names of the form /dev/sd* to /dev/vd* as required. See also: http://libguestfs.org/guestfs.3.html#block_device_naming
* In the daemon, change all const char * parameters to char *.Richard Jones2009-06-101-1/+1
|
* Add: pvresize, sfdisk-N, sfdisk-l, sfdisk-kernel-geomtry, ↵Richard W.M. Jones2009-05-151-43/+0
| | | | sfdisk-disk-geometry commands. Pass --no-reread flag to sfdisk.
* /dev/hd* is also a block device on RHEL 5.Richard Jones2009-05-071-2/+4
|
* Added test suite.Richard Jones2009-04-111-0/+62
|
* Implement list-devices and list-partitions.Richard Jones2009-04-061-0/+133