Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/makefs Revert joergs patch and make it compile in b...



details:   https://anonhg.NetBSD.org/src/rev/920609ea56dc
branches:  trunk
changeset: 789059:920609ea56dc
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Mon Aug 05 18:44:16 2013 +0000

description:
Revert joergs patch and make it compile in both the normal as in the tools
environment by providing the MMC datastructures separately for compat.

diffstat:

 usr.sbin/makefs/udf.c                  |   37 +-----
 usr.sbin/makefs/udf/cdio_mmc_structs.h |  163 +++++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+), 28 deletions(-)

diffs (266 lines):

diff -r d9142d80ac12 -r 920609ea56dc usr.sbin/makefs/udf.c
--- a/usr.sbin/makefs/udf.c     Mon Aug 05 17:12:04 2013 +0000
+++ b/usr.sbin/makefs/udf.c     Mon Aug 05 18:44:16 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.3 2013/08/05 17:12:04 joerg Exp $ */
+/* $NetBSD: udf.c,v 1.4 2013/08/05 18:44:16 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,9 +30,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: udf.c,v 1.3 2013/08/05 17:12:04 joerg Exp $");
-
-#define _EXPOSE_MMC
+__RCSID("$NetBSD: udf.c,v 1.4 2013/08/05 18:44:16 reinoud Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -45,12 +43,16 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/param.h>
-#if !HAVE_NBTOOL_CONFIG_H
-#include <sys/cdio.h>
-#endif
 #include <sys/stat.h>
 #include <util.h>
 
+#if !HAVE_NBTOOL_CONFIG_H
+#define _EXPOSE_MMC
+#include <sys/cdio.h>
+#else
+#include "udf/cdio_mmc_structs.h"
+#endif
+
 #include "makefs.h"
 #include "udf_create.h"
 #include "udf_write.h"
@@ -66,9 +68,7 @@
 /* global variables describing disc and format requests */
 int     fd;                            /* device: file descriptor */
 char   *dev;                           /* device: name            */
-#if !HAVE_NBTOOL_CONFIG_H
 struct mmc_discinfo mmc_discinfo;      /* device: disc info       */
-#endif
 
 char   *format_str;                    /* format: string representation */
 int     format_flags;                  /* format: attribute flags       */
@@ -155,7 +155,6 @@
 
 /* --------------------------------------------------------------------- */
 
-#if !HAVE_NBTOOL_CONFIG_H
 static int
 udf_emulate_discinfo(fsinfo_t *fsopts, struct mmc_discinfo *di,
                int mmc_emuprofile)
@@ -266,16 +265,6 @@
 
        return 0;
 }
-#else
-off_t sectors;
-
-static int
-udf_emulate_discinfo(fsinfo_t *fsopts, int mmc_emuprofile)
-{
-       sectors = fsopts->size / fsopts->sectorsize;
-       return 0;
-}
-#endif
 
 #define OPT_STR(letter, name, desc)  \
        { letter, name, NULL, OPT_STRBUF, 0, 0, desc }
@@ -1184,11 +1173,7 @@
        int error;
 
        /* determine format */
-#if !HAVE_NBTOOL_CONFIG_H
        udf_emulate_discinfo(fsopts, &mmc_discinfo, mmc_profile);
-#else
-       udf_emulate_discinfo(fsopts, mmc_profile);
-#endif
        printf("req_enable %d, req_disable %d\n", req_enable, req_disable);
 
        context.sector_size = fsopts->sectorsize;
@@ -1231,11 +1216,7 @@
        meta_fract = ((int) ((meta_fract + 0.005)*100.0)) / 100;
 
        /* update mmc info but now with correct size */
-#if !HAVE_NBTOOL_CONFIG_H
        udf_emulate_discinfo(fsopts, &mmc_discinfo, mmc_profile);
-#else
-       udf_emulate_discinfo(fsopts, mmc_profile);
-#endif
 
        udf_do_newfs_prefix();
 
diff -r d9142d80ac12 -r 920609ea56dc usr.sbin/makefs/udf/cdio_mmc_structs.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/makefs/udf/cdio_mmc_structs.h    Mon Aug 05 18:44:16 2013 +0000
@@ -0,0 +1,163 @@
+/* $NetBSD: cdio_mmc_structs.h,v 1.1 2013/08/05 18:44:16 reinoud Exp $ */
+
+/*
+ * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ */
+
+#ifndef _CDIO_MMC_EMU_H_
+#define _CDIO_MMC_EMU_H_
+
+#include <sys/types.h>
+
+/*
+ * MMC device abstraction interface.
+ *
+ * It gathers information from GET_CONFIGURATION, READ_DISCINFO,
+ * READ_TRACKINFO, READ_TOC2, READ_CD_CAPACITY and GET_CONFIGURATION
+ * SCSI/ATAPI calls regardless if its a legacy CD-ROM/DVD-ROM device or a MMC
+ * standard recordable device.
+ */
+struct mmc_discinfo {
+       uint16_t        mmc_profile;
+       uint16_t        mmc_class;
+
+       uint8_t         disc_state;
+       uint8_t         last_session_state;
+       uint8_t         bg_format_state;
+       uint8_t         link_block_penalty;     /* in sectors              */
+
+       uint64_t        mmc_cur;                /* current MMC_CAPs        */
+       uint64_t        mmc_cap;                /* possible MMC_CAPs       */
+
+       uint32_t        disc_flags;             /* misc flags              */
+
+       uint32_t        disc_id;
+       uint64_t        disc_barcode;
+       uint8_t         application_code;       /* 8 bit really            */
+
+       uint8_t         unused1[3];             /* padding                 */
+
+       uint32_t        last_possible_lba;      /* last leadout start adr. */
+       uint32_t        sector_size;
+
+       uint16_t        num_sessions;
+       uint16_t        num_tracks;             /* derived */
+
+       uint16_t        first_track;
+       uint16_t        first_track_last_session;
+       uint16_t        last_track_last_session;
+
+       uint16_t        unused2;                /* padding/misc info resv. */
+
+       uint16_t        reserved1[4];           /* MMC-5 track resources   */
+       uint32_t        reserved2[3];           /* MMC-5 POW resources     */
+
+       uint32_t        reserved3[8];           /* MMC-5+ */
+};
+#define MMCGETDISCINFO _IOR('c', 28, struct mmc_discinfo)
+
+#define MMC_CLASS_UNKN  0
+#define MMC_CLASS_DISC 1
+#define MMC_CLASS_CD   2
+#define MMC_CLASS_DVD  3
+#define MMC_CLASS_MO   4
+#define MMC_CLASS_BD   5
+#define MMC_CLASS_FILE 0xffff  /* emulation mode */
+
+#define MMC_DFLAGS_BARCODEVALID        (1 <<  0)  /* barcode is present and valid   */
+#define MMC_DFLAGS_DISCIDVALID  (1 <<  1)  /* discid is present and valid    */
+#define MMC_DFLAGS_APPCODEVALID (1 <<  2)  /* application code valid         */
+#define MMC_DFLAGS_UNRESTRICTED (1 <<  3)  /* restricted, then set app. code */
+
+#define MMC_DFLAGS_FLAGBITS \
+    "\10\1BARCODEVALID\2DISCIDVALID\3APPCODEVALID\4UNRESTRICTED"
+
+#define MMC_CAP_SEQUENTIAL     (1 <<  0)  /* sequential writable only       */
+#define MMC_CAP_RECORDABLE     (1 <<  1)  /* record-able; i.e. not static   */
+#define MMC_CAP_ERASABLE       (1 <<  2)  /* drive can erase sectors        */
+#define MMC_CAP_BLANKABLE      (1 <<  3)  /* media can be blanked           */
+#define MMC_CAP_FORMATTABLE    (1 <<  4)  /* media can be formatted         */
+#define MMC_CAP_REWRITABLE     (1 <<  5)  /* media can be rewritten         */
+#define MMC_CAP_MRW            (1 <<  6)  /* Mount Rainier formatted        */
+#define MMC_CAP_PACKET         (1 <<  7)  /* using packet recording         */
+#define MMC_CAP_STRICTOVERWRITE        (1 <<  8)  /* only writes a packet at a time */
+#define MMC_CAP_PSEUDOOVERWRITE (1 <<  9)  /* overwrite through replacement  */
+#define MMC_CAP_ZEROLINKBLK    (1 << 10)  /* zero link block length capable */
+#define MMC_CAP_HW_DEFECTFREE  (1 << 11)  /* hardware defect management     */
+
+#define MMC_CAP_FLAGBITS \
+    "\10\1SEQUENTIAL\2RECORDABLE\3ERASABLE\4BLANKABLE\5FORMATTABLE" \
+    "\6REWRITABLE\7MRW\10PACKET\11STRICTOVERWRITE\12PSEUDOOVERWRITE" \
+    "\13ZEROLINKBLK\14HW_DEFECTFREE"
+
+#define MMC_STATE_EMPTY                0
+#define MMC_STATE_INCOMPLETE   1
+#define MMC_STATE_FULL         2
+#define MMC_STATE_CLOSED       3
+
+#define MMC_BGFSTATE_UNFORM    0
+#define MMC_BGFSTATE_STOPPED   1
+#define MMC_BGFSTATE_RUNNING   2
+#define        MMC_BGFSTATE_COMPLETED  3
+
+
+struct mmc_trackinfo {
+       uint16_t        tracknr;        /* IN/OUT */
+       uint16_t        sessionnr;
+
+       uint8_t         track_mode;
+       uint8_t         data_mode;
+
+       uint16_t        flags;
+
+       uint32_t        track_start;
+       uint32_t        next_writable;
+       uint32_t        free_blocks;
+       uint32_t        packet_size;
+       uint32_t        track_size;
+       uint32_t        last_recorded;
+};
+#define MMCGETTRACKINFO        _IOWR('c', 29, struct mmc_trackinfo)
+
+#define MMC_TRACKINFO_COPY             (1 <<  0)
+#define MMC_TRACKINFO_DAMAGED          (1 <<  1)
+#define MMC_TRACKINFO_FIXED_PACKET     (1 <<  2)
+#define MMC_TRACKINFO_INCREMENTAL      (1 <<  3)
+#define MMC_TRACKINFO_BLANK            (1 <<  4)
+#define MMC_TRACKINFO_RESERVED         (1 <<  5)
+#define MMC_TRACKINFO_NWA_VALID                (1 <<  6)
+#define MMC_TRACKINFO_LRA_VALID                (1 <<  7)
+#define MMC_TRACKINFO_DATA             (1 <<  8)
+#define MMC_TRACKINFO_AUDIO            (1 <<  9)
+#define MMC_TRACKINFO_AUDIO_4CHAN      (1 << 10)
+#define MMC_TRACKINFO_PRE_EMPH         (1 << 11)
+
+#define MMC_TRACKINFO_FLAGBITS \
+    "\10\1COPY\2DAMAGED\3FIXEDPACKET\4INCREMENTAL\5BLANK" \
+    "\6RESERVED\7NWA_VALID\10LRA_VALID\11DATA\12AUDIO" \
+    "\13AUDIO_4CHAN\14PRE_EMPH"
+
+#endif /* _CDIO_MMC_EMU_H_ */
+



Home | Main Index | Thread Index | Old Index