summaryrefslogtreecommitdiffstats
path: root/libdm/libdm-common.c
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: keep MKNOD type cast cleanZdenek Kabelac2012-08-231-1/+1
| | | | Setup major already a dev_t type before it gets shifted.
* Adjust wordingAlasdair Kergon2012-03-061-1/+1
|
* Check for multiple mangled names in auto mangling mode.Peter Rajnoha2012-03-051-0/+17
| | | | | Auto mode can't deal with multiple mangled names. We can do that while working in hex mode, but in auto mode, this would lead to device name ambiguity.
* Fix dm_task_get_name_unmangled to not unmangle already unmangled name.Peter Rajnoha2012-03-051-2/+7
| | | | | In 'auto' and 'hex' mode, these names are already unmangled on ioctl return. There's no point on trying to do that once again (actually it's a bug!).
* Check whether device names are properly mangled on ioctl return.Peter Rajnoha2012-03-051-0/+8
| | | | | | | Be more strict when unmangling names on ioctl return - require the name to be properly mangled in 'auto' and 'hex' mode. There really should not be any blacklisted character since the names should be renamed already (by means of renaming it directly or running 'dmsetup mangle' for automatic rename).
* Clean up internal mangling interface.Peter Rajnoha2012-03-051-17/+13
|
* Using enum types for enumsZdenek Kabelac2012-02-281-1/+1
| | | | alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
* Fix dm_task_set_name to properly resolve path to dm name.Peter Rajnoha2012-02-281-1/+1
| | | | Wrong variable was checked in _dm_task_set_name_from_path.
* Add DM_DEFAULT_NAME_MANGLING_MODE env. variable to override configured value.Peter Rajnoha2012-02-151-1/+19
| | | | | Just in case of emergency when name mangling code causes any problems so we can override the default value and switch off the mangling globally.
* Add dm_task_get_name_mangled/unmangled to libdevmapper.Peter Rajnoha2012-02-151-0/+88
| | | | | | | | | dm_task_get_name_mangled will always return mangled form of the name while the dm_task_get_name_unmangled will always return unmangled form of the name irrespective of the global setting (dm_set/get_name_mangling_mode). This is handy in situations where we need to detect whether the name is already mangled or not. Also display functions make use of it.
* Mangle device name on dm_task_set_name/newname call if necessary.Peter Rajnoha2012-02-151-51/+217
| | | | | | | | | | If dm_task_set_name/newname is called, the name provided will be automatically translated to correct encoded form with the hex enconding so any character not on udev whitelist will be mangled with \xNN format where NN is hex value of the character used. By default, the name mangling mode used is the one set during configure with the '--with-default-name-mangling' option.
* Fix missing temp_buf init for error pathZdenek Kabelac2012-02-131-4/+4
| | | | In previous commit this was missing, also deallocate in reversed order.
* Do not write to -1 buffer addressZdenek Kabelac2012-02-131-25/+25
| | | | | | | | | | In case of zero bytes would be read from sysfs, it would store '\0' on temp_buf[-1] address. Simplify some buffer length calculation and use strcpy if we've just checked string fits in give buffer. Replace jump label error: with bad: commonly used in libdm.
* Fix fd resource leak in error pathZdenek Kabelac2012-02-081-1/+1
| | | | Use 'goto bad' to cleanup fd on error path.
* Ensure strncpy() function always ends with '\0'Zdenek Kabelac2012-02-081-2/+2
| | | | | Since last character needs to be \0 for string, pass buffer size smaller by 1 byte.
* Fix resource leak of file handleZdenek Kabelac2012-01-251-9/+8
| | | | | Introduces when added dm_device_get_name. Close file handle in all error paths.
* Move dm_task_set_newname from libdm-iface.c to libdm-common.cPeter Rajnoha2012-01-171-0/+21
|
* Add dm_device_get_name to get map name or block device name for given devno.Peter Rajnoha2012-01-111-23/+129
| | | | | | | | | | | | | This is accomplished by reading associated sysfs information. For a dm device, this is /sys/dev/block/major:minor/dm/name (supported in kernel version >= 2.6.29, for older kernels, the behaviour is the same as for non-dm devices). For a non-dm device, this is a readlink on /sys/dev/block/major:minor, e.g. /sys/dev/block/253:0 --> ../../devices/virtual/block/dm-0. The last component of the path is a proper kernel name (block device name). One can request to read only kernel names by setting the 'prefer_kernel_name' argument if needed.
* Add dm_uuid_prefix/dm_set_uuid_prefix for non-lvm users to override hard-codedAlasdair Kergon2012-01-101-0/+26
| | | | | | | LVM- prefix. Try harder not to leave stray empty devices around (locally or remotely) when reverting changes after failures while there are inactive tables.
* Use sysfs to set/get of read-aheadZdenek Kabelac2012-01-091-19/+103
| | | | | | | | If we know major:minor number of device (which is known after resume) we will try to use sysfs to set/get read ahead parameters of device. This avoid potential problem of blocking commands like 'dmsetup info' awaiting for device being usable for open/close - i.e. overfilled thin pool may block such command.
* Make a cleaner split between config tree and config file functionality. MovePetr Rockai2011-12-181-1/+1
| | | | the latter out of libdm.
* Check target type name for DM_MAX_TYPE_NAME lengthZdenek Kabelac2011-11-181-2/+1
| | | | | | | | | | | | | | | | | | | | Avoid creation of target type name when it's longer then DM_MAX_TYPE_NAME (noticed by static analyzer where the sp.target_type might be missing '\0' at the end.) Before patch: $> dmsetup create long 0 1000 looooooooooooooooooooooooooong ^D device-mapper: reload ioctl failed: Invalid argument After patch: $> dmsetup create xxx 0 1000 looooooooooooooooooooooooooong Target type name looooooooooooooooooooooooooong is too long. Command failed
* readlink does not append a null byte to the output string!Peter Rajnoha2011-09-241-0/+1
|
* Add dm_device_has_holders fn to to check use of the device by another device.Peter Rajnoha2011-09-221-0/+100
| | | | | | | | Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. This requires sysfs directory to be correctly set via dm_set_sysfs_dir (/sys by default). If sysfs dir is not used or it's set incorrectly, dm_device_has_{holders,mounted_fs} will return 0!
* Add dm_set_sysfs_dir to libdevmapper to set sysfs location.Peter Rajnoha2011-09-221-8/+30
| | | | Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set.
* Log cookie values when incrementing/decrementing to give clues about races.Alasdair Kergon2011-07-081-6/+30
|
* decode cookie flags in debug msgsAlasdair Kergon2011-07-051-2/+55
|
* Add framework for validation of ioctls. Doesn't do any checks yet.Alasdair Kergon2011-07-011-0/+7
| | | | | | dmsetup --checks libdevmapper: dm_task_enable_checks() lvm.conf: activation/checks=1
* more fixes to readahead etc.Alasdair Kergon2011-06-281-9/+13
|
* Extend debug log messages to distinguish between the 3 states:Alasdair Kergon2011-06-271-7/+18
| | | | trust udev; verify udev; perform dev node operations directly.
* Move udev_only logic inside stacked node op code.Alasdair Kergon2011-06-271-48/+67
| | | | | | (We still need to treat add+readhead+del as a no-op.) Rename udev_fallback to verify_udev_operations. Rename --udevfallback to --verifyudev
* Maintain a count of the number of suspended devices in libdevmapperAlasdair Kergon2011-06-131-0/+23
| | | | | | | | | and use this for the LVM critical section logic. Also report an error if code tries to load a table while any device is known to be in the suspended state. (If the variety of problems these changes are showing up can't be fixed before the next release, the error messages can be reduced to debug level.)
* Require libudev >= 143 when compiling with udev support.Peter Rajnoha2011-04-221-1/+0
| | | | | Old versions of libudev < 143 were experimental and unstable. Require recent and stable versions only (version 143 is old enough anyway).
* Fix 2 signess warnings reported by gccZdenek Kabelac2011-03-301-3/+2
| | | | | Replace int with unsigned counter. Replace snprintf with dm_snprintf.
* Add attribute printfZdenek Kabelac2011-03-291-0/+3
| | | | | gcc suggested to add these attributes to instrumentat printf arguments. Adding it for internal functions as well.
* Improve debug stack traceZdenek Kabelac2011-03-181-1/+1
| | | | dm_check_version reports log_error() - so use return_NULL.
* Lower severity of selabel_lookup and matchpathcon failure to log_debug.Peter Rajnoha2011-03-031-2/+4
|
* Add missing returnZdenek Kabelac2011-03-021-0/+2
|
* Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.Alasdair Kergon2011-03-021-1/+10
| | | | Include an implicit dm_task_update_nodes() within dm_udev_wait().
* pre-releaseAlasdair Kergon2011-02-041-2/+3
|
* Fix operation node stacking for consecutive dm opsZdenek Kabelac2011-02-041-8/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the ability to stack many operations in one udev transaction - in same cases we are adding and removing same device at the same time (i.e. deactivate followed by activate). This leads to a problem of checking stacked operations: i.e. remove /dev/node1 followed by create /dev/node1 If the node creation is handled with udev - there is a problem as stacked operation gives warning about existing node1 and will try to remove it - while next operation needs to recreate it. Current code removes all previous stacked operation if the fs op is FS_DEL - patch adds similar behavior for FS_ADD - it will try to remove any 'delete' operation if udev is in use. For FS_RENAME operation it seems to be more complex. But as we are always stacking FS_READ_AHEAD after FS_ADD operation - should be safe to remove all previous operation on the node when udev is running. Code does same checking for stacking libdm and liblvm operations. As a very simple optimization counters were added for each stacked ops type to avoid unneeded list scans if some operation does not exists in the list. Enable skipping of fs_unlock() (udev sync) if only DEL operations are staked. as we do not use lv_info for already deleted nodes.
* Suport DM_SECURE_DATA_FLAG.Milan Broz2011-02-041-0/+1
| | | | | It will be user for cryptsetup to ensure buffers are properly wiped when sending sensitive data (key).
* Replace fs_unlock by sync_local_dev_names to notify local clvmd. (2.02.80)Alasdair Kergon2011-01-121-1/+1
| | | | Introduce sync_local_dev_names and CLVMD_CMD_SYNC_NAMES to issue fs_unlock.
* HAVE_SELINUX againPeter Rajnoha2010-12-131-2/+2
|
* #ifdef HAVE_SELINUX and #ifdef HAVE_SELINUX_LABEL_HPeter Rajnoha2010-12-131-1/+3
|
* Missing #elif HAVE_SELINUXPeter Rajnoha2010-12-131-1/+1
|
* Add new dm_prepare_selinux_context fn to libdevmapper and use it throughout.Peter Rajnoha2010-12-131-9/+73
| | | | | | | | | | | Detect existence of new SELinux selabel interface during configure. Use new dm_prepare_selinux_context instead of dm_set_selinux_context. We should set the SELinux context before the actual file system object creation. The new dm_prepare_selinux_context function sets this using the selabel_lookup fn in conjuction with the setfscreatecon fn. If selinux/label.h interface (that should be a part of the selinux library) is not found during configure, we fallback to the original matchpathcon function instead.
* Cleanup remove test for NULLZdenek Kabelac2010-11-291-10/+4
| | | | dm_free is testing NULL itself
* Add --setuuid to dmsetup rename.Alasdair Kergon2010-10-151-0/+1
| | | | Add dm_task_set_newuuid to set uuid of mapped device post-creation. (pjones)
* Add dm_zalloc and use it and dm_pool_zalloc throughout.Alasdair Kergon2010-09-301-3/+1
|