Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/fs/udf Pull up following revision(s), all via patch,



details:   https://anonhg.NetBSD.org/src/rev/7930923838f3
branches:  netbsd-9
changeset: 363456:7930923838f3
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Mar 13 09:48:32 2022 +0000

description:
Pull up following revision(s), all via patch,
requested by reinoud in ticket #1432:

        sys/fs/udf/udf_vfsops.c: revision 1.83
        sys/fs/udf/udf_allocation.c: revision 1.45
        sys/fs/udf/udf_subr.c: revision 1.160
        sys/fs/udf/udf_subr.c: revision 1.161

While searching the VAT on recordable media, search the last sector too!
This fixes Win10 formatted discs from being mounted incorrectly.

Make sysctl udf.verbose dependent on UDF_DEBUG instead of DEBUG

Fix serious issue with recordable media formatted with Win10. When closing it
after modification the VAT was written out corrupted making the disc
unreadable anymore on remount. Thanks for ig@ for spotting it in the wild!

On freeing a virtual address in the VAT, use the correct value; this might
confuse other implementations who can reject the VAT on this.

diffstat:

 sys/fs/udf/udf_allocation.c |   6 +++---
 sys/fs/udf/udf_subr.c       |  45 +++++++++++++++++++++++++++++++++------------
 sys/fs/udf/udf_vfsops.c     |   6 +++---
 3 files changed, 39 insertions(+), 18 deletions(-)

diffs (152 lines):

diff -r b24c3e56b5ca -r 7930923838f3 sys/fs/udf/udf_allocation.c
--- a/sys/fs/udf/udf_allocation.c       Sun Mar 13 09:44:33 2022 +0000
+++ b/sys/fs/udf/udf_allocation.c       Sun Mar 13 09:48:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.40.4.1 2022/03/13 09:48:32 martin Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40.4.1 2022/03/13 09:48:32 martin Exp $");
 #endif /* not lint */
 
 
@@ -864,7 +864,7 @@
        }
 
        /* mark entry with initialiser just in case */
-       lb_map = udf_rw32(0xfffffffe);
+       lb_map = udf_rw32(0xffffffff);
        udf_vat_write(ump->vat_node, (uint8_t *) &lb_map, 4,
                ump->vat_offset + lb_num *4);
        ump->vat_last_free_lb = lb_num;
diff -r b24c3e56b5ca -r 7930923838f3 sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c     Sun Mar 13 09:44:33 2022 +0000
+++ b/sys/fs/udf/udf_subr.c     Sun Mar 13 09:48:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.146.2.1 2022/03/13 09:44:33 martin Exp $ */
+/* $NetBSD: udf_subr.c,v 1.146.2.2 2022/03/13 09:48:32 martin Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.146.2.1 2022/03/13 09:44:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.146.2.2 2022/03/13 09:48:32 martin Exp $");
 #endif /* not lint */
 
 
@@ -2764,10 +2764,11 @@
        struct icb_tag *icbtag;
        struct udf_oldvat_tail *oldvat_tl;
        struct udf_vat *vat;
+       struct regid *regid;
        uint64_t unique_id;
        uint32_t lb_size;
        uint8_t *raw_vat;
-       int filetype, error;
+       int vat_length, impl_use_len, filetype, error;
 
        KASSERT(vat_node);
        KASSERT(lvinfo);
@@ -2812,11 +2813,20 @@
                        sizeof(struct udf_oldvat_tail), ump->vat_entries * 4);
        } else {
                /* compose the VAT2 header */
+               vat_length = sizeof(struct udf_vat);
                vat = (struct udf_vat *) raw_vat;
-               memset(vat, 0, sizeof(struct udf_vat));
-
-               vat->header_len       = udf_rw16(152);  /* as per spec */
-               vat->impl_use_len     = udf_rw16(0);
+
+               error = udf_vat_read(vat_node, raw_vat, vat_length, 0);
+               if (error)
+                       goto errout;
+
+               impl_use_len = udf_rw16(vat->impl_use_len);
+               vat_length += impl_use_len;
+
+               error = udf_vat_read(vat_node, raw_vat, vat_length, 0);
+               if (error)
+                       goto errout;
+
                memmove(vat->logvol_id, ump->logical_vol->logvol_id, 128);
                vat->prev_vat         = udf_rw32(0xffffffff);
                vat->num_files        = lvinfo->num_files;
@@ -2825,9 +2835,20 @@
                vat->min_udf_writever = lvinfo->min_udf_writever;
                vat->max_udf_writever = lvinfo->max_udf_writever;
 
-               error = udf_vat_write(vat_node, raw_vat,
-                       sizeof(struct udf_vat), 0);
-       }
+               if (impl_use_len >= sizeof(struct regid)) {
+                       /* insert our implementation identification */
+                       memset(vat->data, 0, impl_use_len);
+                       regid = (struct regid *) vat->data;
+                       udf_set_regid(regid, IMPL_NAME);
+                       udf_add_app_regid(ump, regid);
+               } else {
+                       if (impl_use_len)
+                               memset(vat->data, 0, impl_use_len);
+                       vat->impl_use_len = 0;
+               }
+               error = udf_vat_write(vat_node, raw_vat, vat_length, 0);
+       }
+errout:
        free(raw_vat, M_TEMP);
 
        return error;   /* success! */
@@ -2996,7 +3017,7 @@
 
                /* definition */
                vat = (struct udf_vat *) raw_vat;
-               vat_offset  = vat->header_len;
+               vat_offset  = udf_rw16(vat->header_len);
                vat_entries = (vat_length - vat_offset)/4;
 
                assert(lvinfo);
@@ -3100,7 +3121,7 @@
                        if (vat_node)
                                vput(vat_node->vnode);
                        vat_loc++;      /* walk forward */
-               } while (vat_loc < late_vat_loc);
+               } while (vat_loc <= late_vat_loc);
                if (accepted_vat_node)
                        break;
 
diff -r b24c3e56b5ca -r 7930923838f3 sys/fs/udf/udf_vfsops.c
--- a/sys/fs/udf/udf_vfsops.c   Sun Mar 13 09:44:33 2022 +0000
+++ b/sys/fs/udf/udf_vfsops.c   Sun Mar 13 09:48:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.76 2017/06/24 12:13:16 hannken Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.76.10.1 2022/03/13 09:48:32 martin Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.76 2017/06/24 12:13:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.76.10.1 2022/03/13 09:48:32 martin Exp $");
 #endif /* not lint */
 
 
@@ -191,7 +191,7 @@
                               SYSCTL_DESCR("OSTA Universal File System"),
                               NULL, 0, NULL, 0,
                               CTL_VFS, 24, CTL_EOL);
-#ifdef DEBUG
+#ifdef UDF_DEBUG
                sysctl_createv(&udf_sysctl_log, 0, NULL, &node,
                               CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                               CTLTYPE_INT, "verbose",



Home | Main Index | Thread Index | Old Index