1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
Commit Graph

574 Commits

Author SHA1 Message Date
Zdenek Kabelac
c2915dd1ed Introduce dm_strncpy
Should be faster then strncpy - since we could avoid clearing 4KB pages
with each strncpy(...,PATH_MAX).
Also it's easy to check whether string fit - and eventually avoid
to continue working we incomplete string.
2012-02-23 22:45:43 +00:00
Alasdair Kergon
7a502785b0 post-release 2012-02-23 18:26:28 +00:00
Alasdair Kergon
2a0264eb7d pre-release 2012-02-23 18:22:09 +00:00
Zdenek Kabelac
de61ffd1b5 Limit number of mem allocs and copies
If we have good enough glibc to return number of needed chars, do not
loop try to reach good size, but use this size directly for allocation,
saving also last strdup.

Since now we start with 16 bytes - skip buffer realloc for shorter string.
2012-02-23 18:05:12 +00:00
Alasdair Kergon
6d4df258e4 post-release 2012-02-20 21:11:06 +00:00
Alasdair Kergon
a742ee8b37 pre-release 2012-02-20 19:38:19 +00:00
Peter Rajnoha
a2e5d2cb9c Switch to using built-in blkid in 13-dm-disk.rules.
Available in udev since version 176.
2012-02-16 14:39:02 +00:00
Peter Rajnoha
f71e484598 Add watch rule to 13-dm-disk.rules.
We don't have anything better yet...

The problems the watch rule caused when removing devices should be covered
now with the "retry remove" logic. It's also better to have this maintained
by us, rather than having this rule anywhere else without proper control.
2012-02-15 14:50:33 +00:00
Zdenek Kabelac
735a00a152 Detect failing fifo
If the fifo died because of dmeventd restart - do not wait for 20s
in select  - it will not get better and return error immediately.
2012-02-15 13:56:47 +00:00
Peter Rajnoha
c0b2521a82 Add DM_DEFAULT_NAME_MANGLING_MODE env. variable to override configured value.
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.
2012-02-15 12:23:15 +00:00
Peter Rajnoha
17696422b6 Replace any '\' char with '\\' in table specification on input.
Device-mapper in kernel uses '\' as escape character so it's better
to double it to avoid any confusion when using existing device names
with '\' in the table specification.

For example:

dmsetup create x --table "0 8 linear /dev/mapper/a\x20b 0"

should pass just fine now without a need to explicitly escape the '\' char
like this:

dmsetup create x --table "0 8 linear /dev/mapper/a\\x20b 0"
2012-02-15 12:17:34 +00:00
Peter Rajnoha
7f024cf822 Add mangle command to dmsetup to provide renaming to correct mangled form. 2012-02-15 12:08:57 +00:00
Peter Rajnoha
f2e7993792 Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o. 2012-02-15 12:06:17 +00:00
Peter Rajnoha
5a923ff8ad Add --manglename option to dmsetup to select the name mangling mode. 2012-02-15 12:02:58 +00:00
Peter Rajnoha
9d5d312d82 Add dm_task_get_name_mangled/unmangled to libdevmapper.
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.
2012-02-15 11:39:38 +00:00
Peter Rajnoha
3ffe9aa27d Mangle device name on dm_task_set_name/newname call if necessary.
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.
2012-02-15 11:27:01 +00:00
Peter Rajnoha
cd4fce855e Add configure --with-default-name-mangling.
This option configures the default name mangling mode used, one of:
AUTO, NONE and HEX.

The name mangling is primarily used to support udev character whitelist
(0-9, A-Z, a-z, #*-.:=@_) so any character that is not on udev whitelist
will get translated into an encoded form \xNN where NN is the hex value
of the character.
2012-02-15 11:17:57 +00:00
Zdenek Kabelac
27d46fc686 Make sure dereferenced words[0] and words[1] are defined 2012-02-13 14:17:04 +00:00
Zdenek Kabelac
c868f0ebf0 Ensure allocated device does not leak on error path
For unimplementd canonicalize_file_name set to NULL
2012-02-13 12:06:39 +00:00
Zdenek Kabelac
afed769d42 Check for missing reply_uuid 2012-02-13 11:24:09 +00:00
Zdenek Kabelac
a140caa666 Check for allocation failure 2012-02-13 11:18:45 +00:00
Zdenek Kabelac
2833f81fb3 Add few missing allocation failures tests 2012-02-13 11:13:44 +00:00
Zdenek Kabelac
7cf73cbc1f Do not write to -1 buffer address
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.
2012-02-13 10:49:28 +00:00
Alasdair Kergon
52fdced782 post-release 2012-02-13 00:23:21 +00:00
Alasdair Kergon
2a7e2fe2d3 pre-release 2012-02-12 23:02:52 +00:00
Zdenek Kabelac
777a797ec3 Fix message check
Check pointer from strchr for NULL instead of crash later.
Badly formated message would have crash dmeventd otherwise.
2012-02-10 15:17:52 +00:00
Zdenek Kabelac
c559180cca Check for deps pointer before dererence
As _deps() call may return NULL - check for it.
2012-02-10 14:48:28 +00:00
Zdenek Kabelac
9fde529762 Add validation of name and uuid
Do not accept NULL pointers.
2012-02-10 14:42:28 +00:00
Zdenek Kabelac
50504ab73e Do not crash for NULL sort_key
Guard against NULL pointer for sort_key and let it behave like an empty
string would have been passed in (i.e. no key).
2012-02-10 14:00:07 +00:00
Zdenek Kabelac
514976816d Return error for failing allocation
Fix case, where final strdup would have failed and it would miss to return
failure for this case and return success and NULL pointer.
2012-02-10 13:56:19 +00:00
Zdenek Kabelac
00067fb64a Add test for failing allocation
Avoid memcpy to NULL if realloc fails.
2012-02-10 13:52:05 +00:00
Zdenek Kabelac
f6aab411f8 Add test for memory allocation failures
Replace asserts with test for failing memory allocation.
Add at least stack traces.
Index counter starts from 1 (0 reserved for error), so replacing fingerprint.
2012-02-10 13:49:29 +00:00
Zdenek Kabelac
d735798674 Use dm_asprintf to simplify code 2012-02-08 12:59:19 +00:00
Zdenek Kabelac
fb6a209080 Set all parameters to 0
Since the function dm_get_next_target() returns NULL as 'next' pointer
so it's not a 'real' error - set 0 to all parameters when NULL is
returned because of missing head.

i.e. one of use case::
do {
	next = dm_get_next_target(dmt, next, &start, &length,
				  &target_type, &params);
	size += length;
} while (next);
2012-02-08 11:25:09 +00:00
Zdenek Kabelac
e48d39cba0 Fix fd resource leak in error path
Use 'goto bad' to cleanup fd on error path.
2012-02-08 11:07:17 +00:00
Zdenek Kabelac
4443aa41cc Ensure strncpy() function always ends with '\0'
Since last character needs to be \0 for string,
pass buffer size smaller by 1 byte.
2012-02-08 11:05:04 +00:00
Alasdair Kergon
b93aa9eac4 post-release 2012-02-01 18:46:57 +00:00
Alasdair Kergon
d8e7d0e2bd pre-release 2012-02-01 15:17:04 +00:00
Alasdair Kergon
09e8d81a53 post-release 2012-01-27 01:23:40 +00:00
Alasdair Kergon
f47f37485e pre-release 2012-01-26 14:02:42 +00:00
Alasdair Kergon
3876196da4 pre-release 2012-01-26 10:11:30 +00:00
Zdenek Kabelac
255e8cb60b Ensure whole info is initialised
Since _create_dm_tree_node is copying whole structure,
make sure all members are initialized.
2012-01-25 21:50:50 +00:00
Alasdair Kergon
5c9bebee8a Add dmsetup 'wipe_table' to replace table with one that uses error target. 2012-01-18 18:52:02 +00:00
Peter Rajnoha
8227bf45d1 Support different device name types on output of dmsetup deps, ls and info -c command.
Add 'blkdevname' and 'blkdevs_used' field to dmsetup info -c -o.
Add 'blkdevname' option to dmsetup ls --tree to see block device names.
Add '-o options' to dmsetup deps and ls to select device name type on output.
2012-01-11 12:46:19 +00:00
Peter Rajnoha
ad96b1b460 Add dm_device_get_name to get map name or block device name for given devno.
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.
2012-01-11 12:34:44 +00:00
Alasdair Kergon
ee1e9fcd22 Add dm_uuid_prefix/dm_set_uuid_prefix for non-lvm users to override hard-coded
LVM- prefix.

Try harder not to leave stray empty devices around (locally or remotely) when
reverting changes after failures while there are inactive tables.
2012-01-10 02:03:31 +00:00
Zdenek Kabelac
99a1830b46 Improve readahead in dmsetup man page 2012-01-09 12:28:47 +00:00
Zdenek Kabelac
6cf41f5503 Use sysfs to set/get of read-ahead
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.
2012-01-09 12:26:14 +00:00
Zdenek Kabelac
6298758992 Add dm_config_find_str_allow_empty
Support empty string values.
2011-12-21 12:47:44 +00:00
Peter Rajnoha
999263f18d Fix lvm2-monitor init script to use normalized output when using vgs. 2011-12-07 12:29:41 +00:00