linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] libdevmapper's handling of devices with spaces in the name
@ 2014-02-26 17:04 Phillip Susi
  2014-02-26 18:21 ` Zdenek Kabelac
  0 siblings, 1 reply; 10+ messages in thread
From: Phillip Susi @ 2014-02-26 17:04 UTC (permalink / raw)
  To: LVM general discussion and development

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

So if I tell dmsetup to create a device named 'foo bar' it ends up
actually naming it 'foo\x20bar'.  If I run parted on 'foo\x20bar', it
appears that libdevmapper helpfully tries to unescape the name,
returning 'foo bar' from dm_task_get_name().  Unfortunately, such a
dev node does not actually exist so this creates a problem trying to
open it.

This seems like a bug in libdevmapper.  I'd say the name of the actual
dev node should not be escaped in the first place.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTDh6oAAoJEI5FoCIzSKrwDQgH/ikb56o0nnptlD98L1dW9LNi
pZQL7IixpwVCLHrI2DBIZvtGAQKgrN16lMLIkLnH7LzRXNaw9Lkw/QG9Jgs+Zibm
fd5yYTgHlOCCsw8OEIOoXLT3YRWB6fjsWrGuFo9/SnJQpZVjxeLCGoopIkusNd6A
aP8BnX4iWl/eJgs/4gOuFjbimckDui5jYnp4ZJ8ena7a+tv1H/rywPkboOlKrz2+
/dI9WMJYFyUYqaVgZCXstBStCQTF6156HZAkB+qqwAo2um9SP+yQlU7zqixieK9T
h/Rd7MuDHPe+TObNVmLRRXJ1+c2yoEKa8ra8WH+C/G7u2V6qtzZf0CfSMzk0p+A=
=wPZ8
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 17:04 [linux-lvm] libdevmapper's handling of devices with spaces in the name Phillip Susi
@ 2014-02-26 18:21 ` Zdenek Kabelac
  2014-02-26 18:37   ` Phillip Susi
  0 siblings, 1 reply; 10+ messages in thread
From: Zdenek Kabelac @ 2014-02-26 18:21 UTC (permalink / raw)
  To: LVM general discussion and development, psusi

Dne 26.2.2014 18:04, Phillip Susi napsal(a):
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> So if I tell dmsetup to create a device named 'foo bar' it ends up
> actually naming it 'foo\x20bar'.  If I run parted on 'foo\x20bar', it
> appears that libdevmapper helpfully tries to unescape the name,
> returning 'foo bar' from dm_task_get_name().  Unfortunately, such a
> dev node does not actually exist so this creates a problem trying to
> open it.
>
> This seems like a bug in libdevmapper.  I'd say the name of the actual
> dev node should not be escaped in the first place.

This is no longer true for 'modern' systems with udev.

libdevmapper no longer creates any /dev nodes - it's all job for udev.

And udev has had in dark ages the idea to use 'space' as a separator
for device names in device list. Thus it 'invented' escaping/mangling names.
(There are more prohibited characters which used to be used for normal device 
names (see man dmsetup mangling))

If you have system without udev - you could disable name mangling on i.e. 
dmsetup cmdline.

There is also envvar DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME
which could be used to set prefered behavior.

So there is no bug in libdm side - but I'll not comment on the rest...

I'll just note - it really means all tools now would need to be fixed to 
handle udev mangled names properly...

Regards

Zdenek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 18:21 ` Zdenek Kabelac
@ 2014-02-26 18:37   ` Phillip Susi
  2014-02-26 19:12     ` Zdenek Kabelac
  0 siblings, 1 reply; 10+ messages in thread
From: Phillip Susi @ 2014-02-26 18:37 UTC (permalink / raw)
  To: Zdenek Kabelac, LVM general discussion and development

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/26/2014 1:21 PM, Zdenek Kabelac wrote:
> This is no longer true for 'modern' systems with udev.
> 
> libdevmapper no longer creates any /dev nodes - it's all job for
> udev.
> 
> And udev has had in dark ages the idea to use 'space' as a
> separator for device names in device list. Thus it 'invented'
> escaping/mangling names. (There are more prohibited characters
> which used to be used for normal device names (see man dmsetup
> mangling))
> 
> If you have system without udev - you could disable name mangling
> on i.e. dmsetup cmdline.

So it is doing this to try and work around a bug in udev.  Has this
been fixed in modern udev and should be safe to disable?  It doesn't
seem to work for me when I do with udev 204: I end up with
/dev/mapper/foo.

> There is also envvar DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME 
> which could be used to set prefered behavior.
> 
> So there is no bug in libdm side - but I'll not comment on the
> rest...

The bug in libdm is that it is lieing to the calling application about
the name of the device, claiming it is not escaped, when in fact, it
is.  Or is dm_task_get_name() supposed to return a human readable
string rather than the actual file name?  If that is the case, how to
get the actual file name instead?


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTDjRkAAoJEI5FoCIzSKrwpAcIAJz9UAGH5KRTZphdC5TBnfiH
+5Hvpeep1gjO/W5mnsjNw7/Y1fP9W+vGKnJj2GUY4nlB0iVYoDxR6M8dTUkBKgZr
M+4hkxUdco8I/oik9uFZrF8YhcHIEsFJrhpAD/RDgsq7YiLD+U6bxAnR9O+OdCyG
hJh3GuKhEXf/A6D2sc89F06mg+7e2m44Yn/rjaYdQaYXISQ34++1lkrjZ8co8gDz
UWkPnoTwSJPuMhhhNXhBvSKxwl7J0SYC9E53D3uBChnHc3zfWoR21h8MxZ9EdUgD
sVA0HLZdxZrkbAiaw7p0YW8KZhEcT0Khsn+X/oagB/EqJBT5MXioHZIuAJk2nFw=
=hzdN
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 18:37   ` Phillip Susi
@ 2014-02-26 19:12     ` Zdenek Kabelac
  2014-02-26 20:52       ` Phillip Susi
  0 siblings, 1 reply; 10+ messages in thread
From: Zdenek Kabelac @ 2014-02-26 19:12 UTC (permalink / raw)
  To: Phillip Susi, LVM general discussion and development

Dne 26.2.2014 19:37, Phillip Susi napsal(a):
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2/26/2014 1:21 PM, Zdenek Kabelac wrote:
>> This is no longer true for 'modern' systems with udev.
>>
>> libdevmapper no longer creates any /dev nodes - it's all job for
>> udev.
>>
>> And udev has had in dark ages the idea to use 'space' as a
>> separator for device names in device list. Thus it 'invented'
>> escaping/mangling names. (There are more prohibited characters
>> which used to be used for normal device names (see man dmsetup
>> mangling))
>>
>> If you have system without udev - you could disable name mangling
>> on i.e. dmsetup cmdline.
>
> So it is doing this to try and work around a bug in udev.  Has this
> been fixed in modern udev and should be safe to disable?  It doesn't

Unfortunately this is seen as a 'feature' of udev - so there is no plan to fix 
it in udev - since too many other things depends on the current naming logic 
(i.e all udev rules scripts written in bash would need major fixes to work 
with characters which are nontrivil to work with)
All surrounding Gnome above it as well - you would be really amazed if you 
would check this deeply...


> seem to work for me when I do with udev 204: I end up with
> /dev/mapper/foo.
>
>> There is also envvar DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME
>> which could be used to set prefered behavior.
>>
>> So there is no bug in libdm side - but I'll not comment on the
>> rest...
>
> The bug in libdm is that it is lieing to the calling application about
> the name of the device, claiming it is not escaped, when in fact, it
> is.  Or is dm_task_get_name() supposed to return a human readable
> string rather than the actual file name?  If that is the case, how to
> get the actual file name instead?

As said - there is no bug in libdm - libdm expects udev to create nodes.
You can reconfigure libdm to do this job instead of udev - but then nothing 
else will work with it - so it's basically dead-road...

The best you can do is to not use names which needs mangling - that's my best 
suggestions (and lvm team already spend countless hours on some usable 
workarounds and solutions...)

For mangling see 'dmsetup mangle' help - how to obtain device names...

Zdenek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 19:12     ` Zdenek Kabelac
@ 2014-02-26 20:52       ` Phillip Susi
  2014-02-26 21:40         ` Zdenek Kabelac
  0 siblings, 1 reply; 10+ messages in thread
From: Phillip Susi @ 2014-02-26 20:52 UTC (permalink / raw)
  To: Zdenek Kabelac, LVM general discussion and development

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/26/2014 2:12 PM, Zdenek Kabelac wrote:
> As said - there is no bug in libdm - libdm expects udev to create
> nodes. You can reconfigure libdm to do this job instead of udev -
> but then nothing else will work with it - so it's basically
> dead-road...

It doesn't matter who creates it, what matters is that when parted
asks what the correct name is, that it be told the name that actually
is created.

> The best you can do is to not use names which needs mangling -
> that's my best suggestions (and lvm team already spend countless
> hours on some usable workarounds and solutions...)

Unfortunately, it seems that a number of hardware vendors ship
preconfigured fakeraid setups with a space in the name of the volume.

> For mangling see 'dmsetup mangle' help - how to obtain device
> names...

Is there a libdevmapper call to do this?


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTDlQcAAoJEI5FoCIzSKrw3Z8H/3pS3uLG9vcQOrVba4KMxjN6
PY1uPGCWIUyqiGUYxzyleyAXp7TVyNpvomPEuevToSaEQBjL60jBUW1NNSiqPmsz
Dk9DDGzF7ecmQ3p4w6jPn0+RBKNvLU1jZygxCsMW3A9c2iqhuICkKD+MMDzjj2bw
Af/M6fT8aJBUWCeLeT+egKY2vVHP59j0AyNwj2ei4pBZ+Y2gOoecJTB+kZB7VgJ+
MoY8VdQaQGhMKQLtmmkD5kIDbe7x8f1mYj4y1BUhzvnemu4vpFn7s5wOE41+9cTk
F5J0GWE6OgNQ3oXLktpkt50hQH72rAOOrnlzEpx/SobH6l1oEtB0XpJdyVuiIAc=
=kiNS
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 20:52       ` Phillip Susi
@ 2014-02-26 21:40         ` Zdenek Kabelac
  2014-02-26 22:17           ` Phillip Susi
  0 siblings, 1 reply; 10+ messages in thread
From: Zdenek Kabelac @ 2014-02-26 21:40 UTC (permalink / raw)
  To: Phillip Susi, LVM general discussion and development

Dne 26.2.2014 21:52, Phillip Susi napsal(a):
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2/26/2014 2:12 PM, Zdenek Kabelac wrote:
>> As said - there is no bug in libdm - libdm expects udev to create
>> nodes. You can reconfigure libdm to do this job instead of udev -
>> but then nothing else will work with it - so it's basically
>> dead-road...
>
> It doesn't matter who creates it, what matters is that when parted
> asks what the correct name is, that it be told the name that actually
> is created.
>

I assume you will need to learn why it does matter - it's the crucial part of 
this puzzle - but it's surely not a topic for lvm-devel list.

And as I've also already said - yes it really does mean that many userspace 
tools need be adapted to handle things in more user friendly way.


>> The best you can do is to not use names which needs mangling -
>> that's my best suggestions (and lvm team already spend countless
>> hours on some usable workarounds and solutions...)
>
> Unfortunately, it seems that a number of hardware vendors ship
> preconfigured fakeraid setups with a space in the name of the volume.

It have to be dealt with them properly on user level part.
User level needs to use some different names for such devices.

It's currently highly discouraged to create devices with 'prohibited' 
characters in them - since the rest will fail to process them properly.

You really can't expect  udev will start to support spaces in names....
So tools like 'mount' will need to know how to translate...

>
>> For mangling see 'dmsetup mangle' help - how to obtain device
>> names...
>
> Is there a libdevmapper call to do this?
>


https://git.fedorahosted.org/cgit/lvm2.git/tree/libdm/libdevmapper.h

Look for 'mangle' in function names.

For 'howto' look at dmsetup.c source code:

https://git.fedorahosted.org/cgit/lvm2.git/tree/tools/dmsetup.c

There is not much better doc for these function unfortunately.
I'd strongly advise to stay on 'dmsetup' level of usage.

It would also probably help to describe what kind of app which uses 
libdevmapper you are trying to develop...

Regards

Zdenek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 21:40         ` Zdenek Kabelac
@ 2014-02-26 22:17           ` Phillip Susi
  2014-02-26 23:26             ` Alasdair G Kergon
                               ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Phillip Susi @ 2014-02-26 22:17 UTC (permalink / raw)
  To: Zdenek Kabelac, LVM general discussion and development

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/26/2014 4:40 PM, Zdenek Kabelac wrote:
> It would also probably help to describe what kind of app which
> uses libdevmapper you are trying to develop...

I'm trying to fix parted to not fail on such devices.  As I said
originally it fails because it calls dm_task_get_name() to find out
the true /dev/mapper/ name of the device, so that it can add the
partition number to it and be able to open the partition.  Now that I
look at the comment in the headers, it sounds like perhaps it just
should be using dm_task_get_name_mangled() instead.

I'm also still wondering why udev can't simply handle quoted names
with spaces in them.  People have been dealing with this sort of thing
in shell for years...


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTDmfpAAoJEI5FoCIzSKrw+0YH/3i/a7dihHXuM1nGxkL16E+e
Er2X7PoVnowBKVW7kk9bHXKOO5vZeSAArcYflmgcernBXTjBhyXFi8wtwuxtWIRc
nesNV26dQz5I7Qh9l9tVt9kCuCwGs/UT/V4vnyPAIf+O5pnwFyy32d2CjnMVztTa
QBRmS9CoeurQkj5s+BFGI+vyM3Uul5SA3Ymaf/qIWC8xQXMNUisro5ytwzXT5tJ5
jT5yK754wxw8V6bgFOTBssOaLKOetMklMHSgfW2+XWuhFduGNAOdeM5dbqJlW1Wr
RSxEaTu4EvvuBcnYe/APuuOW6JUwG+Uf4Ut/gyMoWc8dRKXsPb2UMm694FRy8Rk=
=6ZPG
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 22:17           ` Phillip Susi
@ 2014-02-26 23:26             ` Alasdair G Kergon
  2014-02-27  8:51             ` Peter Rajnoha
  2014-02-27  9:08             ` Peter Rajnoha
  2 siblings, 0 replies; 10+ messages in thread
From: Alasdair G Kergon @ 2014-02-26 23:26 UTC (permalink / raw)
  To: Phillip Susi; +Cc: LVM general discussion and development, Zdenek Kabelac

On Wed, Feb 26, 2014 at 05:17:13PM -0500, Phillip Susi wrote:
> I'm also still wondering why udev can't simply handle quoted names
> with spaces in them.  People have been dealing with this sort of thing
> in shell for years...
 
Once you've had exposure to udev you soon learn that "wondering why" gets
you nowhere:)  However bizarre, your only option is to conform.
Name mangling in lvm2/device-mapper was designed both to conform and
to still allow for all possibilities in as transparent a way as we could.

The primary new limitation is a reduction in the effective maximum length
of a device name due to the quoting.  If this becomes a problem we will have
to extend the kernal API to support longer names.

Alasdair

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 22:17           ` Phillip Susi
  2014-02-26 23:26             ` Alasdair G Kergon
@ 2014-02-27  8:51             ` Peter Rajnoha
  2014-02-27  9:08             ` Peter Rajnoha
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Rajnoha @ 2014-02-27  8:51 UTC (permalink / raw)
  To: psusi; +Cc: LVM general discussion and development

On 02/26/2014 11:17 PM, Phillip Susi wrote:
> I'm also still wondering why udev can't simply handle quoted names
> with spaces in them.  People have been dealing with this sort of thing
> in shell for years...

We tried that: https://bugzilla.redhat.com/show_bug.cgi?id=736486#c12

And this was not the only request from us to fix something in udev.
But based on previous experience, we concluded that it was just useless
to try spending time with persuading the other side.

If you have enough nerves to argue with them, I'm really and sincerely
wishing you good luck.
-- 
Peter

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [linux-lvm] libdevmapper's handling of devices with spaces in the name
  2014-02-26 22:17           ` Phillip Susi
  2014-02-26 23:26             ` Alasdair G Kergon
  2014-02-27  8:51             ` Peter Rajnoha
@ 2014-02-27  9:08             ` Peter Rajnoha
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Rajnoha @ 2014-02-27  9:08 UTC (permalink / raw)
  To: psusi; +Cc: LVM general discussion and development

On 02/26/2014 11:17 PM, Phillip Susi wrote:
> I'm trying to fix parted to not fail on such devices.  As I said
> originally it fails because it calls dm_task_get_name() to find out
> the true /dev/mapper/ name of the device, so that it can add the
> partition number to it and be able to open the partition.  Now that I
> look at the comment in the headers, it sounds like perhaps it just
> should be using dm_task_get_name_mangled() instead.

Yes, you can call that fn to get the name in its actual "mangled" form
as it appears in /dev/mapper.

-- 
Peter

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-02-27  9:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-26 17:04 [linux-lvm] libdevmapper's handling of devices with spaces in the name Phillip Susi
2014-02-26 18:21 ` Zdenek Kabelac
2014-02-26 18:37   ` Phillip Susi
2014-02-26 19:12     ` Zdenek Kabelac
2014-02-26 20:52       ` Phillip Susi
2014-02-26 21:40         ` Zdenek Kabelac
2014-02-26 22:17           ` Phillip Susi
2014-02-26 23:26             ` Alasdair G Kergon
2014-02-27  8:51             ` Peter Rajnoha
2014-02-27  9:08             ` Peter Rajnoha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).