NetBSD-Bugs archive

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

Re: port-arm/47081: Wrong offset and size in MBR partition on armeb.



> RCS file: /cvsroot/src/sys/arch/arm/arm/disksubr_mbr.c,v
> +             LE32TOH(mbrp->mbrp_start);
> +             LE32TOH(mbrp->mbrp_size);

Isn't it better to "swap on copying between on-disk-format and host-variable"
to avoid confusion?


Index: disksubr_mbr.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm/disksubr_mbr.c,v
retrieving revision 1.13
diff -u -p -r1.13 disksubr_mbr.c
--- disksubr_mbr.c      2 Dec 2011 00:25:37 -0000       1.13
+++ disksubr_mbr.c      15 Oct 2012 14:58:07 -0000
@@ -151,23 +151,23 @@ mbr_label_read(dev_t dev,
 
                        /* Install in partition e, f, g, or h. */
                        pp = &lp->d_partitions['e' - 'a' + i];
-                       pp->p_offset = mbrp->mbrp_start;
-                       pp->p_size = mbrp->mbrp_size;
+                       pp->p_offset = le32toh(mbrp->mbrp_start);
+                       pp->p_size = le32toh(mbrp->mbrp_size);
                        pp->p_fstype = xlat_mbr_fstype(mbrp->mbrp_type);
 
                        /* is this ours? */
                        if (mbrp == ourmbrp) {
                                /* need sector address for SCSI/IDE,
                                 cylinder for ESDI/ST506/RLL */
-                               mbrpartoff = mbrp->mbrp_start;
+                               mbrpartoff = le32toh(mbrp->mbrp_start);
                                cyl = MBR_PCYL(mbrp->mbrp_scyl, 
mbrp->mbrp_ssect);
 
 #ifdef __i386__ /* XXX? */
                                /* update disklabel with details */
                                lp->d_partitions[2].p_size =
-                                   mbrp->mbrp_size;
+                                   le32toh(mbrp->mbrp_size);
                                lp->d_partitions[2].p_offset = 
-                                   mbrp->mbrp_start;
+                                   le32toh(mbrp->mbrp_start);
                                lp->d_ntracks = mbrp->mbrp_ehd + 1;
                                lp->d_nsectors = MBR_PSECT(mbrp->mbrp_esect);
                                lp->d_secpercyl =
@@ -250,7 +250,7 @@ mbr_label_locate(dev_t dev,
        }
 
        /* need sector address for SCSI/IDE, cylinder for ESDI/ST506/RLL */
-       mbrpartoff = ourmbrp->mbrp_start;
+       mbrpartoff = le32toh(ourmbrp->mbrp_start);
        cyl = MBR_PCYL(ourmbrp->mbrp_scyl, ourmbrp->mbrp_ssect);
 
        *cylp = cyl;


Home | Main Index | Thread Index | Old Index