Re: [dm-devel] [PATCH v6 0/3] dm: boot a mapped device without an initramfs

2017-05-04 Thread Alasdair G Kergon
Some more thoughts with your example, dmsetup might look like:

# dmsetup create --bootformat "lroot:uuid,rw,0 2097152 linear 8:2 0, \
2097152 2097152 linear 8:3 0, 4194304 2097152 linear 8:4 0"

- also supporting creating multiple devices if the semi-colon is used

- colon to separate name from uuid, like we already do major:minor 
- colon to separate other flags from rw if we need them in future

- splitting first on a unescaped semi-colons, then on the first two
unescaped commas, and then on unescaped commas and then unescaped spaces
within the table

- backslash escapes the following character so it is never a treated
as a separator
  - lroot\:uuid\;\\\ \"\, would be a device with no uuid and the name
lroot:uuid;\ ",  (on a non-udev system without name mangling)

# dmsetup ls --bootformat lroot
dm="lroot:uuid,rw,0 2097152 linear 8:2 0, 2097152 2097152 \
linear 8:3 0, 4194304 2097152 linear 8:4 0"

# dmsetup ls --bootformat
(all devices on one output line)

While the code also supports devices in the /dev/sda2 format for 
convenience, please use the preferred 8:2 format in any implementation
and documented examples (to avoid the unnecessary dependency on /dev and
its dependencies).

Or with some alternative name for the option
--boot[format|param]
--short[format]
--kernelparam
--condensed
other suggestions?

dmsetup create --condensed
dmsetup ls --condensed

Alasdair



Re: [dm-devel] [PATCH v6 0/3] dm: boot a mapped device without an initramfs

2017-05-04 Thread Alasdair G Kergon
Some more thoughts with your example, dmsetup might look like:

# dmsetup create --bootformat "lroot:uuid,rw,0 2097152 linear 8:2 0, \
2097152 2097152 linear 8:3 0, 4194304 2097152 linear 8:4 0"

- also supporting creating multiple devices if the semi-colon is used

- colon to separate name from uuid, like we already do major:minor 
- colon to separate other flags from rw if we need them in future

- splitting first on a unescaped semi-colons, then on the first two
unescaped commas, and then on unescaped commas and then unescaped spaces
within the table

- backslash escapes the following character so it is never a treated
as a separator
  - lroot\:uuid\;\\\ \"\, would be a device with no uuid and the name
lroot:uuid;\ ",  (on a non-udev system without name mangling)

# dmsetup ls --bootformat lroot
dm="lroot:uuid,rw,0 2097152 linear 8:2 0, 2097152 2097152 \
linear 8:3 0, 4194304 2097152 linear 8:4 0"

# dmsetup ls --bootformat
(all devices on one output line)

While the code also supports devices in the /dev/sda2 format for 
convenience, please use the preferred 8:2 format in any implementation
and documented examples (to avoid the unnecessary dependency on /dev and
its dependencies).

Or with some alternative name for the option
--boot[format|param]
--short[format]
--kernelparam
--condensed
other suggestions?

dmsetup create --condensed
dmsetup ls --condensed

Alasdair



Re: [dm-devel] [PATCH v6 0/3] dm: boot a mapped device without an initramfs

2017-05-04 Thread Alasdair G Kergon
On Thu, May 04, 2017 at 01:18:41PM +0200, Enric Balletbo Serra wrote:
> I'm wondering if a command line like this would be acceptable.

1) Make sure the implementation continues to support backslash quoting
so that any characters you introduce with special meanings (comma,
semi-colon, double-quote in that example) can still be used if required.

2) "none" is of course a valid uuid:)  More comma-separation or
re-ordering, perhaps?
 
3) Whatever final format is agreed here should be supported by dmsetup
as well, so you can both supply the format to dmsetup and ask dmsetup
to display your existing devices in this format.  Choose a format
that makes this easy.

Alasdair



Re: [dm-devel] [PATCH v6 0/3] dm: boot a mapped device without an initramfs

2017-05-04 Thread Alasdair G Kergon
On Thu, May 04, 2017 at 01:18:41PM +0200, Enric Balletbo Serra wrote:
> I'm wondering if a command line like this would be acceptable.

1) Make sure the implementation continues to support backslash quoting
so that any characters you introduce with special meanings (comma,
semi-colon, double-quote in that example) can still be used if required.

2) "none" is of course a valid uuid:)  More comma-separation or
re-ordering, perhaps?
 
3) Whatever final format is agreed here should be supported by dmsetup
as well, so you can both supply the format to dmsetup and ask dmsetup
to display your existing devices in this format.  Choose a format
that makes this easy.

Alasdair



Re: [dm-devel] [PATCH v6 0/3] dm: boot a mapped device without an initramfs

2017-05-04 Thread Enric Balletbo Serra
Mike,

2017-04-18 19:37 GMT+02:00 Kees Cook :
> On Tue, Apr 18, 2017 at 9:42 AM, Enric Balletbo i Serra
>  wrote:
>> Hello,
>>
>> Some of these patches were send few years back, I saw that first
>> version was send to this list in 2010, and after version 4 did not
>> land [1]. Some days ago I resend the patches [2] and few hours later I
>> noticed that one year ago was send a v5 version [3] and I was not aware.
>>
>> There was some discussion about v5 and during the discussion Mike Snitzer
>> proposed that at least a change of the syntax is required, we're really
>> interested on see this upstream as is extensively used in ChromeOS based
>> devices so I'm wondering if we can restart the discussion and hopefully
>> we will be able to do the modifications needed.
>>
>> So my first question is, apart of the change of the syntax, what more
>> should be changed?
>
> AFAIK, this was the main change needed. Change the syntax and plumb
> into the ioctl interface. The discussion ended with Mike being open to
> the idea, and for me to go work on it. I haven't had time to work on
> it, though, so it has continued to be a locally carried patch:
> https://www.redhat.com/archives/dm-devel/2016-February/msg00199.html
>

>From your email:

> >> > 2) If you are able to adequately justify the need for dm=:
> >> > I'd much rather the dm= kernel commandline be a simple series of
> >> > comma-delimited dmsetup-like commands.
> >> >
> >> > You'd handle each command with extremely basic parsing:
> >> >[,  ]
> >> > (inventing a special token to denote , to support tables with
> >> > multiple entries, rather than relying on commas and counts, etc)
> >>

I'm wondering if a command line like this would be acceptable.

Format is:
  dm="  ,  [, ][; 
 ,  [, ]][; ... ]"

where:
   ::=  The device name
::=  ---- | "none"
  ::= "ro" | "rw"
   ::=   


An example of booting to a linear array:

 dm="lroot none rw, 0 2097152 linear /dev/sda2 0, 2097152 2097152
linear /dev/sda3 0, 4194304 2097152 linear /dev/sda4 0"

Equivalent dmsetup command:

echo -e "0 2097152 linear /dev/sda2 0"\\n"2097152 2097152 linear
/dev/sda3 0"\\n"4194304 2097152 linear /dev/sda4 0" | sudo dmsetup
create lroot

An example of multiple device-mappers, with the dm="..." contents shown
here split on multiple lines for readability:

vroot none ro,
  0 2097152 verity 1 /dev/sdb2 /dev/sdb3 4096 4096 262144 1 sha256 \
  289b52edac1ac4f4c32c8f765795615a85d4daa454677d21a6d8767c4627dc48 \
  632d7fe427a23a8e88493c553298a779997478a143d86da5d56a65db8a1f2a38;
vram none rw,
  0 32768 linear 1:0 0,
  32768 32768 linear 1:1 0

Thanks,
 Enric

> More recently David Zeuthen has been poking at this code, so I've
> included him on CC here, in case there are new developments.
>
> -Kees
>
>>
>> Thanks for your help,
>>  Enric
>>
>> [1] Patchwork links:
>> https://patchwork.kernel.org/patch/104857/
>> https://patchwork.kernel.org/patch/104856/
>> https://patchwork.kernel.org/patch/104858/
>>
>> [2] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1375276.html
>>
>> [3] https://www.redhat.com/archives/dm-devel/2016-February/msg00112.html
>>
>>
>> Brian Norris (1):
>>   dm: make some mapped_device functions available
>>
>> Will Drewry (2):
>>   dm: export a table+mapped device to the ioctl interface
>>   init: add support to directly boot to a mapped device
>>
>>  Documentation/admin-guide/kernel-parameters.rst |   1 +
>>  Documentation/admin-guide/kernel-parameters.txt |   3 +
>>  Documentation/device-mapper/boot.txt|  65 
>>  drivers/md/dm-ioctl.c   |  36 ++
>>  drivers/md/dm.h |   8 -
>>  include/linux/device-mapper.h   |  19 +
>>  init/Makefile   |   1 +
>>  init/do_mounts.c|   1 +
>>  init/do_mounts.h|  10 +
>>  init/do_mounts_dm.c | 448 
>> 
>>  10 files changed, 584 insertions(+), 8 deletions(-)
>>  create mode 100644 Documentation/device-mapper/boot.txt
>>  create mode 100644 init/do_mounts_dm.c
>>
>> --
>> 2.9.3
>>
>
>
>
> --
> Kees Cook
> Pixel Security
>
> --
> dm-devel mailing list
> dm-de...@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel


Re: [dm-devel] [PATCH v6 0/3] dm: boot a mapped device without an initramfs

2017-05-04 Thread Enric Balletbo Serra
Mike,

2017-04-18 19:37 GMT+02:00 Kees Cook :
> On Tue, Apr 18, 2017 at 9:42 AM, Enric Balletbo i Serra
>  wrote:
>> Hello,
>>
>> Some of these patches were send few years back, I saw that first
>> version was send to this list in 2010, and after version 4 did not
>> land [1]. Some days ago I resend the patches [2] and few hours later I
>> noticed that one year ago was send a v5 version [3] and I was not aware.
>>
>> There was some discussion about v5 and during the discussion Mike Snitzer
>> proposed that at least a change of the syntax is required, we're really
>> interested on see this upstream as is extensively used in ChromeOS based
>> devices so I'm wondering if we can restart the discussion and hopefully
>> we will be able to do the modifications needed.
>>
>> So my first question is, apart of the change of the syntax, what more
>> should be changed?
>
> AFAIK, this was the main change needed. Change the syntax and plumb
> into the ioctl interface. The discussion ended with Mike being open to
> the idea, and for me to go work on it. I haven't had time to work on
> it, though, so it has continued to be a locally carried patch:
> https://www.redhat.com/archives/dm-devel/2016-February/msg00199.html
>

>From your email:

> >> > 2) If you are able to adequately justify the need for dm=:
> >> > I'd much rather the dm= kernel commandline be a simple series of
> >> > comma-delimited dmsetup-like commands.
> >> >
> >> > You'd handle each command with extremely basic parsing:
> >> >[,  ]
> >> > (inventing a special token to denote , to support tables with
> >> > multiple entries, rather than relying on commas and counts, etc)
> >>

I'm wondering if a command line like this would be acceptable.

Format is:
  dm="  ,  [, ][; 
 ,  [, ]][; ... ]"

where:
   ::=  The device name
::=  ---- | "none"
  ::= "ro" | "rw"
   ::=   


An example of booting to a linear array:

 dm="lroot none rw, 0 2097152 linear /dev/sda2 0, 2097152 2097152
linear /dev/sda3 0, 4194304 2097152 linear /dev/sda4 0"

Equivalent dmsetup command:

echo -e "0 2097152 linear /dev/sda2 0"\\n"2097152 2097152 linear
/dev/sda3 0"\\n"4194304 2097152 linear /dev/sda4 0" | sudo dmsetup
create lroot

An example of multiple device-mappers, with the dm="..." contents shown
here split on multiple lines for readability:

vroot none ro,
  0 2097152 verity 1 /dev/sdb2 /dev/sdb3 4096 4096 262144 1 sha256 \
  289b52edac1ac4f4c32c8f765795615a85d4daa454677d21a6d8767c4627dc48 \
  632d7fe427a23a8e88493c553298a779997478a143d86da5d56a65db8a1f2a38;
vram none rw,
  0 32768 linear 1:0 0,
  32768 32768 linear 1:1 0

Thanks,
 Enric

> More recently David Zeuthen has been poking at this code, so I've
> included him on CC here, in case there are new developments.
>
> -Kees
>
>>
>> Thanks for your help,
>>  Enric
>>
>> [1] Patchwork links:
>> https://patchwork.kernel.org/patch/104857/
>> https://patchwork.kernel.org/patch/104856/
>> https://patchwork.kernel.org/patch/104858/
>>
>> [2] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1375276.html
>>
>> [3] https://www.redhat.com/archives/dm-devel/2016-February/msg00112.html
>>
>>
>> Brian Norris (1):
>>   dm: make some mapped_device functions available
>>
>> Will Drewry (2):
>>   dm: export a table+mapped device to the ioctl interface
>>   init: add support to directly boot to a mapped device
>>
>>  Documentation/admin-guide/kernel-parameters.rst |   1 +
>>  Documentation/admin-guide/kernel-parameters.txt |   3 +
>>  Documentation/device-mapper/boot.txt|  65 
>>  drivers/md/dm-ioctl.c   |  36 ++
>>  drivers/md/dm.h |   8 -
>>  include/linux/device-mapper.h   |  19 +
>>  init/Makefile   |   1 +
>>  init/do_mounts.c|   1 +
>>  init/do_mounts.h|  10 +
>>  init/do_mounts_dm.c | 448 
>> 
>>  10 files changed, 584 insertions(+), 8 deletions(-)
>>  create mode 100644 Documentation/device-mapper/boot.txt
>>  create mode 100644 init/do_mounts_dm.c
>>
>> --
>> 2.9.3
>>
>
>
>
> --
> Kees Cook
> Pixel Security
>
> --
> dm-devel mailing list
> dm-de...@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel