linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
@ 2020-01-12 14:47 Pali Rohár
  2020-01-13 11:48 ` Jan Kara
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-01-12 14:47 UTC (permalink / raw)
  To: linux-fsdevel, Jan Kara, Steven J. Magnani

[-- Attachment #1: Type: text/plain, Size: 2652 bytes --]

Hello!

Commit b085fbe2ef7fa (udf: Fix crash during mount) introduced check that
UDF disk with PD_ACCESS_TYPE_REWRITABLE access type would not be able to
mount in R/W mode. This commit was added in Linux 4.20.

But most tools which generate UDF filesystem for CD-RW set access type
to rewritable, so above change basically disallow usage of CD-RW discs
formatted to UDF in R/W mode.

Linux's cdrwtool and mkudffs (in all released versions), Windows Nero 6,
NetBSD's newfs_udf -- all these tools uses rewritable access type for
CD-RW media.

In UDF 1.50, 2.00 and 2.01 specification there is no information which
UDF access type should be used for CD-RW medias.

In UDF 2.60, section 2.2.14.2 is written:

    A partition with Access Type 3 (rewritable) shall define a Freed
    Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
    shall not define a Freed Space Bitmap or a Freed Space Table.

    Rewritable partitions are used on media that require some form of
    preprocessing before re-writing data (for example legacy MO). Such
    partitions shall use Access Type 3.

    Overwritable partitions are used on media that do not require
    preprocessing before overwriting data (for example: CD-RW, DVD-RW,
    DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
    use Access Type 4.

And in 6.14.1 (Properties of CD-MRW and DVD+MRW media and drives) is:

    The Media Type is Overwritable (partition Access Type 4,
    overwritable)

Similar info is in UDF 2.50.

So I think that UDF 2.60 is clear that for CD-RW medias (formatted in
normal or MRW mode) should be used Overwritable access type. But all
mentioned tools were probably written prior to existence of UDF 2.60
specifications, probably targeting only UDF 1.50 versions at that time.

I checked that they use Unallocated Space Bitmap (and not Freed Space
Bitmap), so writing to these filesystems should not be a problem.

How to handle this situation? UDF 2.01 nor 1.50 does not say anything
for access type on CD-RW and there are already tools which generates UDF
1.50 images which does not matches UDF 2.60 requirements.

I think that the best would be to relax restrictions added in commit
b085fbe2ef7fa to allow mounting mounting udf fs with rewritable access
type in R/W mode if Freed Space Bitmap/Table is not used.

I'm really not sure if existing udf implementations take CD-RW media
with overwritable media type. E.g. prehistoric wrudf tool refuse to work
with optical discs which have overwritable access type. I supports only
UDF 1.50.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
  2020-01-12 14:47 udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support Pali Rohár
@ 2020-01-13 11:48 ` Jan Kara
  2020-01-16 15:46   ` Pali Rohár
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kara @ 2020-01-13 11:48 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linux-fsdevel, Jan Kara, Steven J. Magnani

Hello,

On Sun 12-01-20 15:47:35, Pali Rohár wrote:
> Commit b085fbe2ef7fa (udf: Fix crash during mount) introduced check that
> UDF disk with PD_ACCESS_TYPE_REWRITABLE access type would not be able to
> mount in R/W mode. This commit was added in Linux 4.20.
> 
> But most tools which generate UDF filesystem for CD-RW set access type
> to rewritable, so above change basically disallow usage of CD-RW discs
> formatted to UDF in R/W mode.
> 
> Linux's cdrwtool and mkudffs (in all released versions), Windows Nero 6,
> NetBSD's newfs_udf -- all these tools uses rewritable access type for
> CD-RW media.
> 
> In UDF 1.50, 2.00 and 2.01 specification there is no information which
> UDF access type should be used for CD-RW medias.
> 
> In UDF 2.60, section 2.2.14.2 is written:
> 
>     A partition with Access Type 3 (rewritable) shall define a Freed
>     Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
>     shall not define a Freed Space Bitmap or a Freed Space Table.
> 
>     Rewritable partitions are used on media that require some form of
>     preprocessing before re-writing data (for example legacy MO). Such
>     partitions shall use Access Type 3.
> 
>     Overwritable partitions are used on media that do not require
>     preprocessing before overwriting data (for example: CD-RW, DVD-RW,
>     DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
>     use Access Type 4.
> 
> And in 6.14.1 (Properties of CD-MRW and DVD+MRW media and drives) is:
> 
>     The Media Type is Overwritable (partition Access Type 4,
>     overwritable)
> 
> Similar info is in UDF 2.50.

Thanks for detailed info. Yes, UDF 2.60 spec is why I've added the check
you mentioned. I was not aware that the phrasing was not there in earlier
versions and frankly even the UDF 2.60 spec is already 15 years old... But
the fact that there are tools creating non-compliant disks certainly
changes the picture :)

> So I think that UDF 2.60 is clear that for CD-RW medias (formatted in
> normal or MRW mode) should be used Overwritable access type. But all
> mentioned tools were probably written prior to existence of UDF 2.60
> specifications, probably targeting only UDF 1.50 versions at that time.
> 
> I checked that they use Unallocated Space Bitmap (and not Freed Space
> Bitmap), so writing to these filesystems should not be a problem.
> 
> How to handle this situation? UDF 2.01 nor 1.50 does not say anything
> for access type on CD-RW and there are already tools which generates UDF
> 1.50 images which does not matches UDF 2.60 requirements.
> 
> I think that the best would be to relax restrictions added in commit
> b085fbe2ef7fa to allow mounting mounting udf fs with rewritable access
> type in R/W mode if Freed Space Bitmap/Table is not used.
> 
> I'm really not sure if existing udf implementations take CD-RW media
> with overwritable media type. E.g. prehistoric wrudf tool refuse to work
> with optical discs which have overwritable access type. I supports only
> UDF 1.50.

Yeah, we should maintain compatibility with older tools where sanely
possible. So I agree with what you propose. Allow writing to
PD_ACCESS_TYPE_REWRITABLE disks if they don't use 'Freed Space
Bitmap/Table'. Will you send a patch or should I do the update?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
  2020-01-13 11:48 ` Jan Kara
@ 2020-01-16 15:46   ` Pali Rohár
  2020-01-17 11:22     ` Jan Kara
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-01-16 15:46 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel, Steven J. Magnani

On Monday 13 January 2020 12:48:38 Jan Kara wrote:
> Hello,
> 
> On Sun 12-01-20 15:47:35, Pali Rohár wrote:
> > Commit b085fbe2ef7fa (udf: Fix crash during mount) introduced check that
> > UDF disk with PD_ACCESS_TYPE_REWRITABLE access type would not be able to
> > mount in R/W mode. This commit was added in Linux 4.20.
> > 
> > But most tools which generate UDF filesystem for CD-RW set access type
> > to rewritable, so above change basically disallow usage of CD-RW discs
> > formatted to UDF in R/W mode.
> > 
> > Linux's cdrwtool and mkudffs (in all released versions), Windows Nero 6,
> > NetBSD's newfs_udf -- all these tools uses rewritable access type for
> > CD-RW media.
> > 
> > In UDF 1.50, 2.00 and 2.01 specification there is no information which
> > UDF access type should be used for CD-RW medias.
> > 
> > In UDF 2.60, section 2.2.14.2 is written:
> > 
> >     A partition with Access Type 3 (rewritable) shall define a Freed
> >     Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
> >     shall not define a Freed Space Bitmap or a Freed Space Table.
> > 
> >     Rewritable partitions are used on media that require some form of
> >     preprocessing before re-writing data (for example legacy MO). Such
> >     partitions shall use Access Type 3.
> > 
> >     Overwritable partitions are used on media that do not require
> >     preprocessing before overwriting data (for example: CD-RW, DVD-RW,
> >     DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
> >     use Access Type 4.
> > 
> > And in 6.14.1 (Properties of CD-MRW and DVD+MRW media and drives) is:
> > 
> >     The Media Type is Overwritable (partition Access Type 4,
> >     overwritable)
> > 
> > Similar info is in UDF 2.50.
> 
> Thanks for detailed info. Yes, UDF 2.60 spec is why I've added the check
> you mentioned. I was not aware that the phrasing was not there in earlier
> versions and frankly even the UDF 2.60 spec is already 15 years old... But
> the fact that there are tools creating non-compliant disks certainly
> changes the picture :)

I tested also Nero Linux 4 (Nero provides free trial version which is
fully working even in 2020) and it creates 1.50 CD-RW discs in the same
way with Rewritable partition. Interestingly for 2.50 and 2.60 it does
not use Overwritable, but Writeonce (yes, for CD-RW with Spartable).

And because previous UDF specification do not say anything about it, I
would not sat that those discs are non-compliant.

Moreover, is there any tool (for Linux or other system) which uses
Overwritable partition type for CD-RW discs? All which I tested uses
Rewritable.

> > So I think that UDF 2.60 is clear that for CD-RW medias (formatted in
> > normal or MRW mode) should be used Overwritable access type. But all
> > mentioned tools were probably written prior to existence of UDF 2.60
> > specifications, probably targeting only UDF 1.50 versions at that time.
> > 
> > I checked that they use Unallocated Space Bitmap (and not Freed Space
> > Bitmap), so writing to these filesystems should not be a problem.
> > 
> > How to handle this situation? UDF 2.01 nor 1.50 does not say anything
> > for access type on CD-RW and there are already tools which generates UDF
> > 1.50 images which does not matches UDF 2.60 requirements.
> > 
> > I think that the best would be to relax restrictions added in commit
> > b085fbe2ef7fa to allow mounting mounting udf fs with rewritable access
> > type in R/W mode if Freed Space Bitmap/Table is not used.
> > 
> > I'm really not sure if existing udf implementations take CD-RW media
> > with overwritable media type. E.g. prehistoric wrudf tool refuse to work
> > with optical discs which have overwritable access type. I supports only
> > UDF 1.50.
> 
> Yeah, we should maintain compatibility with older tools where sanely
> possible. So I agree with what you propose. Allow writing to
> PD_ACCESS_TYPE_REWRITABLE disks if they don't use 'Freed Space
> Bitmap/Table'. Will you send a patch or should I do the update?

Could you do it, please?

Also question is, what with those 2.50 CD-RW Writonce partitions and
with Spartable which creates Nero Linux?

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
  2020-01-16 15:46   ` Pali Rohár
@ 2020-01-17 11:22     ` Jan Kara
  2020-01-17 11:31       ` Pali Rohár
  2020-01-17 11:35       ` Pali Rohár
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Kara @ 2020-01-17 11:22 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Jan Kara, linux-fsdevel, Steven J. Magnani

[-- Attachment #1: Type: text/plain, Size: 4816 bytes --]

On Thu 16-01-20 16:46:43, Pali Rohár wrote:
> On Monday 13 January 2020 12:48:38 Jan Kara wrote:
> > Hello,
> > 
> > On Sun 12-01-20 15:47:35, Pali Rohár wrote:
> > > Commit b085fbe2ef7fa (udf: Fix crash during mount) introduced check that
> > > UDF disk with PD_ACCESS_TYPE_REWRITABLE access type would not be able to
> > > mount in R/W mode. This commit was added in Linux 4.20.
> > > 
> > > But most tools which generate UDF filesystem for CD-RW set access type
> > > to rewritable, so above change basically disallow usage of CD-RW discs
> > > formatted to UDF in R/W mode.
> > > 
> > > Linux's cdrwtool and mkudffs (in all released versions), Windows Nero 6,
> > > NetBSD's newfs_udf -- all these tools uses rewritable access type for
> > > CD-RW media.
> > > 
> > > In UDF 1.50, 2.00 and 2.01 specification there is no information which
> > > UDF access type should be used for CD-RW medias.
> > > 
> > > In UDF 2.60, section 2.2.14.2 is written:
> > > 
> > >     A partition with Access Type 3 (rewritable) shall define a Freed
> > >     Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
> > >     shall not define a Freed Space Bitmap or a Freed Space Table.
> > > 
> > >     Rewritable partitions are used on media that require some form of
> > >     preprocessing before re-writing data (for example legacy MO). Such
> > >     partitions shall use Access Type 3.
> > > 
> > >     Overwritable partitions are used on media that do not require
> > >     preprocessing before overwriting data (for example: CD-RW, DVD-RW,
> > >     DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
> > >     use Access Type 4.
> > > 
> > > And in 6.14.1 (Properties of CD-MRW and DVD+MRW media and drives) is:
> > > 
> > >     The Media Type is Overwritable (partition Access Type 4,
> > >     overwritable)
> > > 
> > > Similar info is in UDF 2.50.
> > 
> > Thanks for detailed info. Yes, UDF 2.60 spec is why I've added the check
> > you mentioned. I was not aware that the phrasing was not there in earlier
> > versions and frankly even the UDF 2.60 spec is already 15 years old... But
> > the fact that there are tools creating non-compliant disks certainly
> > changes the picture :)
> 
> I tested also Nero Linux 4 (Nero provides free trial version which is
> fully working even in 2020) and it creates 1.50 CD-RW discs in the same
> way with Rewritable partition. Interestingly for 2.50 and 2.60 it does
> not use Overwritable, but Writeonce (yes, for CD-RW with Spartable).
> 
> And because previous UDF specification do not say anything about it, I
> would not sat that those discs are non-compliant.
> 
> Moreover, is there any tool (for Linux or other system) which uses
> Overwritable partition type for CD-RW discs? All which I tested uses
> Rewritable.

No. But CD-RW means that the media needs "erasing" before overwriting so
using 'Rewritable' partitions there is fine and in the kernel we do want to
force such mounts read-only because we don't support "erasing", do we?

> > > So I think that UDF 2.60 is clear that for CD-RW medias (formatted in
> > > normal or MRW mode) should be used Overwritable access type. But all
> > > mentioned tools were probably written prior to existence of UDF 2.60
> > > specifications, probably targeting only UDF 1.50 versions at that time.
> > > 
> > > I checked that they use Unallocated Space Bitmap (and not Freed Space
> > > Bitmap), so writing to these filesystems should not be a problem.
> > > 
> > > How to handle this situation? UDF 2.01 nor 1.50 does not say anything
> > > for access type on CD-RW and there are already tools which generates UDF
> > > 1.50 images which does not matches UDF 2.60 requirements.
> > > 
> > > I think that the best would be to relax restrictions added in commit
> > > b085fbe2ef7fa to allow mounting mounting udf fs with rewritable access
> > > type in R/W mode if Freed Space Bitmap/Table is not used.
> > > 
> > > I'm really not sure if existing udf implementations take CD-RW media
> > > with overwritable media type. E.g. prehistoric wrudf tool refuse to work
> > > with optical discs which have overwritable access type. I supports only
> > > UDF 1.50.
> > 
> > Yeah, we should maintain compatibility with older tools where sanely
> > possible. So I agree with what you propose. Allow writing to
> > PD_ACCESS_TYPE_REWRITABLE disks if they don't use 'Freed Space
> > Bitmap/Table'. Will you send a patch or should I do the update?
> 
> Could you do it, please?

Sure, attached.

> Also question is, what with those 2.50 CD-RW Writonce partitions and
> with Spartable which creates Nero Linux?

Well, we force them read-only and that's what we should do because we don't
support CD-RW in the kernel... But I may be missing something.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[-- Attachment #2: 0001-udf-Allow-writing-to-Rewritable-partitions.patch --]
[-- Type: text/x-patch, Size: 2030 bytes --]

From 8ca0a73ae4f07ba8d0cbb4cdb8f8362bd378beed Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Fri, 17 Jan 2020 12:11:14 +0100
Subject: [PATCH] udf: Allow writing to 'Rewritable' partitions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

UDF 2.60 standard states in section 2.2.14.2:

    A partition with Access Type 3 (rewritable) shall define a Freed
    Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
    shall not define a Freed Space Bitmap or a Freed Space Table.

    Rewritable partitions are used on media that require some form of
    preprocessing before re-writing data (for example legacy MO). Such
    partitions shall use Access Type 3.

    Overwritable partitions are used on media that do not require
    preprocessing before overwriting data (for example: CD-RW, DVD-RW,
    DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
    use Access Type 4.

however older versions of the standard didn't have this wording and
there are tools out there that create UDF filesystems with rewritable
partitions but that don't contain a Freed Space Bitmap or a Freed Space
Table on media that does not require pre-processing before overwriting a
block. So instead of forcing media with rewritable partition read-only,
base this decision on presence of a Freed Space Bitmap or a Freed Space
Table.

Reported-by: Pali Rohár <pali.rohar@gmail.com>
Link: https://lore.kernel.org/linux-fsdevel/20200112144735.hj2emsoy4uwsouxz@pali
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 96d001a4a844..fd96d7bfc0e4 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1035,7 +1035,6 @@ static int check_partition_desc(struct super_block *sb,
 	switch (le32_to_cpu(p->accessType)) {
 	case PD_ACCESS_TYPE_READ_ONLY:
 	case PD_ACCESS_TYPE_WRITE_ONCE:
-	case PD_ACCESS_TYPE_REWRITABLE:
 	case PD_ACCESS_TYPE_NONE:
 		goto force_ro;
 	}
-- 
2.16.4


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

* Re: udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
  2020-01-17 11:22     ` Jan Kara
@ 2020-01-17 11:31       ` Pali Rohár
  2020-01-17 12:27         ` Jan Kara
  2020-01-17 11:35       ` Pali Rohár
  1 sibling, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-01-17 11:31 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel, Steven J. Magnani

On Friday 17 January 2020 12:22:54 Jan Kara wrote:
> On Thu 16-01-20 16:46:43, Pali Rohár wrote:
> > On Monday 13 January 2020 12:48:38 Jan Kara wrote:
> > > Hello,
> > > 
> > > On Sun 12-01-20 15:47:35, Pali Rohár wrote:
> > > > Commit b085fbe2ef7fa (udf: Fix crash during mount) introduced check that
> > > > UDF disk with PD_ACCESS_TYPE_REWRITABLE access type would not be able to
> > > > mount in R/W mode. This commit was added in Linux 4.20.
> > > > 
> > > > But most tools which generate UDF filesystem for CD-RW set access type
> > > > to rewritable, so above change basically disallow usage of CD-RW discs
> > > > formatted to UDF in R/W mode.
> > > > 
> > > > Linux's cdrwtool and mkudffs (in all released versions), Windows Nero 6,
> > > > NetBSD's newfs_udf -- all these tools uses rewritable access type for
> > > > CD-RW media.
> > > > 
> > > > In UDF 1.50, 2.00 and 2.01 specification there is no information which
> > > > UDF access type should be used for CD-RW medias.
> > > > 
> > > > In UDF 2.60, section 2.2.14.2 is written:
> > > > 
> > > >     A partition with Access Type 3 (rewritable) shall define a Freed
> > > >     Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
> > > >     shall not define a Freed Space Bitmap or a Freed Space Table.
> > > > 
> > > >     Rewritable partitions are used on media that require some form of
> > > >     preprocessing before re-writing data (for example legacy MO). Such
> > > >     partitions shall use Access Type 3.
> > > > 
> > > >     Overwritable partitions are used on media that do not require
> > > >     preprocessing before overwriting data (for example: CD-RW, DVD-RW,
> > > >     DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
> > > >     use Access Type 4.
> > > > 
> > > > And in 6.14.1 (Properties of CD-MRW and DVD+MRW media and drives) is:
> > > > 
> > > >     The Media Type is Overwritable (partition Access Type 4,
> > > >     overwritable)
> > > > 
> > > > Similar info is in UDF 2.50.
> > > 
> > > Thanks for detailed info. Yes, UDF 2.60 spec is why I've added the check
> > > you mentioned. I was not aware that the phrasing was not there in earlier
> > > versions and frankly even the UDF 2.60 spec is already 15 years old... But
> > > the fact that there are tools creating non-compliant disks certainly
> > > changes the picture :)
> > 
> > I tested also Nero Linux 4 (Nero provides free trial version which is
> > fully working even in 2020) and it creates 1.50 CD-RW discs in the same
> > way with Rewritable partition. Interestingly for 2.50 and 2.60 it does
> > not use Overwritable, but Writeonce (yes, for CD-RW with Spartable).
> > 
> > And because previous UDF specification do not say anything about it, I
> > would not sat that those discs are non-compliant.
> > 
> > Moreover, is there any tool (for Linux or other system) which uses
> > Overwritable partition type for CD-RW discs? All which I tested uses
> > Rewritable.
> 
> No. But CD-RW means that the media needs "erasing" before overwriting so
> using 'Rewritable' partitions there is fine and in the kernel we do want to
> force such mounts read-only because we don't support "erasing", do we?

I guess that this formulation as you wrote is the reason why all
formatting tools decided to use Overwritable type for CD-RW.

But it is not completely truth. You need erase CD-RW before formatting,
not before rewriting blocks on it. And kernel already supports rewriting
one random block on CD-RW media via pktcdvd.ko layer (part of mainline
kernel).

So to mount CD-RW media with UDF fs on it in R/W mode, you need:

1) erase & format CD-RW media (e.g. via cdrwtool)
2) setup pktcdvd layer for CD-RW media (e.g. via pktsetup or via /sys)
3) mount pktcdvd block device with udf fs

So, kernel supports UDF on CD-RW media also in R/W mode, just it is not
straightforward as for other hard disk block devices.

> > > > So I think that UDF 2.60 is clear that for CD-RW medias (formatted in
> > > > normal or MRW mode) should be used Overwritable access type. But all
> > > > mentioned tools were probably written prior to existence of UDF 2.60
> > > > specifications, probably targeting only UDF 1.50 versions at that time.
> > > > 
> > > > I checked that they use Unallocated Space Bitmap (and not Freed Space
> > > > Bitmap), so writing to these filesystems should not be a problem.
> > > > 
> > > > How to handle this situation? UDF 2.01 nor 1.50 does not say anything
> > > > for access type on CD-RW and there are already tools which generates UDF
> > > > 1.50 images which does not matches UDF 2.60 requirements.
> > > > 
> > > > I think that the best would be to relax restrictions added in commit
> > > > b085fbe2ef7fa to allow mounting mounting udf fs with rewritable access
> > > > type in R/W mode if Freed Space Bitmap/Table is not used.
> > > > 
> > > > I'm really not sure if existing udf implementations take CD-RW media
> > > > with overwritable media type. E.g. prehistoric wrudf tool refuse to work
> > > > with optical discs which have overwritable access type. I supports only
> > > > UDF 1.50.
> > > 
> > > Yeah, we should maintain compatibility with older tools where sanely
> > > possible. So I agree with what you propose. Allow writing to
> > > PD_ACCESS_TYPE_REWRITABLE disks if they don't use 'Freed Space
> > > Bitmap/Table'. Will you send a patch or should I do the update?
> > 
> > Could you do it, please?
> 
> Sure, attached.
> 
> > Also question is, what with those 2.50 CD-RW Writonce partitions and
> > with Spartable which creates Nero Linux?
> 
> Well, we force them read-only and that's what we should do because we don't
> support CD-RW in the kernel... But I may be missing something.

We support CD-RW in kernel, but now I realized that we do not support
UDF 2.50 in R/W mode. So this should be OK for now (until UDF 2.50 R/W
mode is implemented).

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
  2020-01-17 11:22     ` Jan Kara
  2020-01-17 11:31       ` Pali Rohár
@ 2020-01-17 11:35       ` Pali Rohár
  1 sibling, 0 replies; 7+ messages in thread
From: Pali Rohár @ 2020-01-17 11:35 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel, Steven J. Magnani

On Friday 17 January 2020 12:22:54 Jan Kara wrote:
> On Thu 16-01-20 16:46:43, Pali Rohár wrote:
> > On Monday 13 January 2020 12:48:38 Jan Kara wrote:
> > > On Sun 12-01-20 15:47:35, Pali Rohár wrote:
> > > > So I think that UDF 2.60 is clear that for CD-RW medias (formatted in
> > > > normal or MRW mode) should be used Overwritable access type. But all
> > > > mentioned tools were probably written prior to existence of UDF 2.60
> > > > specifications, probably targeting only UDF 1.50 versions at that time.
> > > > 
> > > > I checked that they use Unallocated Space Bitmap (and not Freed Space
> > > > Bitmap), so writing to these filesystems should not be a problem.
> > > > 
> > > > How to handle this situation? UDF 2.01 nor 1.50 does not say anything
> > > > for access type on CD-RW and there are already tools which generates UDF
> > > > 1.50 images which does not matches UDF 2.60 requirements.
> > > > 
> > > > I think that the best would be to relax restrictions added in commit
> > > > b085fbe2ef7fa to allow mounting mounting udf fs with rewritable access
> > > > type in R/W mode if Freed Space Bitmap/Table is not used.
> > > > 
> > > > I'm really not sure if existing udf implementations take CD-RW media
> > > > with overwritable media type. E.g. prehistoric wrudf tool refuse to work
> > > > with optical discs which have overwritable access type. I supports only
> > > > UDF 1.50.
> > > 
> > > Yeah, we should maintain compatibility with older tools where sanely
> > > possible. So I agree with what you propose. Allow writing to
> > > PD_ACCESS_TYPE_REWRITABLE disks if they don't use 'Freed Space
> > > Bitmap/Table'. Will you send a patch or should I do the update?
> > 
> > Could you do it, please?
> 
> Sure, attached.

Looks good, just you have specified wrong MIME enc: charset=iso-8859-1
It should be UTF-8. You can add my Reviewed-by keyword.

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support
  2020-01-17 11:31       ` Pali Rohár
@ 2020-01-17 12:27         ` Jan Kara
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kara @ 2020-01-17 12:27 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Jan Kara, linux-fsdevel, Steven J. Magnani

On Fri 17-01-20 12:31:47, Pali Rohár wrote:
> On Friday 17 January 2020 12:22:54 Jan Kara wrote:
> > On Thu 16-01-20 16:46:43, Pali Rohár wrote:
> > > On Monday 13 January 2020 12:48:38 Jan Kara wrote:
> > > > Hello,
> > > > 
> > > > On Sun 12-01-20 15:47:35, Pali Rohár wrote:
> > > > > Commit b085fbe2ef7fa (udf: Fix crash during mount) introduced check that
> > > > > UDF disk with PD_ACCESS_TYPE_REWRITABLE access type would not be able to
> > > > > mount in R/W mode. This commit was added in Linux 4.20.
> > > > > 
> > > > > But most tools which generate UDF filesystem for CD-RW set access type
> > > > > to rewritable, so above change basically disallow usage of CD-RW discs
> > > > > formatted to UDF in R/W mode.
> > > > > 
> > > > > Linux's cdrwtool and mkudffs (in all released versions), Windows Nero 6,
> > > > > NetBSD's newfs_udf -- all these tools uses rewritable access type for
> > > > > CD-RW media.
> > > > > 
> > > > > In UDF 1.50, 2.00 and 2.01 specification there is no information which
> > > > > UDF access type should be used for CD-RW medias.
> > > > > 
> > > > > In UDF 2.60, section 2.2.14.2 is written:
> > > > > 
> > > > >     A partition with Access Type 3 (rewritable) shall define a Freed
> > > > >     Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
> > > > >     shall not define a Freed Space Bitmap or a Freed Space Table.
> > > > > 
> > > > >     Rewritable partitions are used on media that require some form of
> > > > >     preprocessing before re-writing data (for example legacy MO). Such
> > > > >     partitions shall use Access Type 3.
> > > > > 
> > > > >     Overwritable partitions are used on media that do not require
> > > > >     preprocessing before overwriting data (for example: CD-RW, DVD-RW,
> > > > >     DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
> > > > >     use Access Type 4.
> > > > > 
> > > > > And in 6.14.1 (Properties of CD-MRW and DVD+MRW media and drives) is:
> > > > > 
> > > > >     The Media Type is Overwritable (partition Access Type 4,
> > > > >     overwritable)
> > > > > 
> > > > > Similar info is in UDF 2.50.
> > > > 
> > > > Thanks for detailed info. Yes, UDF 2.60 spec is why I've added the check
> > > > you mentioned. I was not aware that the phrasing was not there in earlier
> > > > versions and frankly even the UDF 2.60 spec is already 15 years old... But
> > > > the fact that there are tools creating non-compliant disks certainly
> > > > changes the picture :)
> > > 
> > > I tested also Nero Linux 4 (Nero provides free trial version which is
> > > fully working even in 2020) and it creates 1.50 CD-RW discs in the same
> > > way with Rewritable partition. Interestingly for 2.50 and 2.60 it does
> > > not use Overwritable, but Writeonce (yes, for CD-RW with Spartable).
> > > 
> > > And because previous UDF specification do not say anything about it, I
> > > would not sat that those discs are non-compliant.
> > > 
> > > Moreover, is there any tool (for Linux or other system) which uses
> > > Overwritable partition type for CD-RW discs? All which I tested uses
> > > Rewritable.
> > 
> > No. But CD-RW means that the media needs "erasing" before overwriting so
> > using 'Rewritable' partitions there is fine and in the kernel we do want to
> > force such mounts read-only because we don't support "erasing", do we?
> 
> I guess that this formulation as you wrote is the reason why all
> formatting tools decided to use Overwritable type for CD-RW.
> 
> But it is not completely truth. You need erase CD-RW before formatting,
> not before rewriting blocks on it. And kernel already supports rewriting
> one random block on CD-RW media via pktcdvd.ko layer (part of mainline
> kernel).
> 
> So to mount CD-RW media with UDF fs on it in R/W mode, you need:
> 
> 1) erase & format CD-RW media (e.g. via cdrwtool)
> 2) setup pktcdvd layer for CD-RW media (e.g. via pktsetup or via /sys)
> 3) mount pktcdvd block device with udf fs
> 
> So, kernel supports UDF on CD-RW media also in R/W mode, just it is not
> straightforward as for other hard disk block devices.

Ah, OK, thanks for clarification.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2020-01-17 12:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-12 14:47 udf: Commit b085fbe2ef7fa (udf: Fix crash during mount) broke CD-RW support Pali Rohár
2020-01-13 11:48 ` Jan Kara
2020-01-16 15:46   ` Pali Rohár
2020-01-17 11:22     ` Jan Kara
2020-01-17 11:31       ` Pali Rohár
2020-01-17 12:27         ` Jan Kara
2020-01-17 11:35       ` Pali Rohár

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).