Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Allow building UDF parts of makefs on !NetBSD.
details: https://anonhg.NetBSD.org/src/rev/d9142d80ac12
branches: trunk
changeset: 789058:d9142d80ac12
user: joerg <joerg%NetBSD.org@localhost>
date: Mon Aug 05 17:12:04 2013 +0000
description:
Allow building UDF parts of makefs on !NetBSD.
diffstat:
sbin/newfs_udf/newfs_udf.h | 4 ++
sbin/newfs_udf/udf_create.c | 23 ++++++++++++++--
sbin/newfs_udf/udf_create.h | 6 +++-
sbin/newfs_udf/udf_write.c | 61 +++++++++++++++++++++++++++++++++++++++++---
sbin/newfs_udf/udf_write.h | 2 +
usr.sbin/makefs/udf.c | 33 ++++++++++++++++++++---
6 files changed, 114 insertions(+), 15 deletions(-)
diffs (truncated from 422 to 300 lines):
diff -r dc2b5817744e -r d9142d80ac12 sbin/newfs_udf/newfs_udf.h
--- a/sbin/newfs_udf/newfs_udf.h Mon Aug 05 17:02:54 2013 +0000
+++ b/sbin/newfs_udf/newfs_udf.h Mon Aug 05 17:12:04 2013 +0000
@@ -41,7 +41,9 @@
/* global variables describing disc and format requests */
extern int fd; /* device: file descriptor */
extern char *dev; /* device: name */
+#if !HAVE_NBTOOL_CONFIG_H
extern struct mmc_discinfo mmc_discinfo; /* device: disc info */
+#endif
extern char *format_str; /* format: string representation */
extern int format_flags; /* format: attribute flags */
@@ -59,7 +61,9 @@
/* prototypes */
int udf_write_sector(void *sector, uint32_t location);
+#if !HAVE_NBTOOL_CONFIG_H
int udf_update_trackinfo(struct mmc_discinfo *di, struct mmc_trackinfo *ti);
+#endif
/* tmp */
int writeout_write_queue(void);
diff -r dc2b5817744e -r d9142d80ac12 sbin/newfs_udf/udf_create.c
--- a/sbin/newfs_udf/udf_create.c Mon Aug 05 17:02:54 2013 +0000
+++ b/sbin/newfs_udf/udf_create.c Mon Aug 05 17:12:04 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.19 2013/08/05 16:44:58 reinoud Exp $ */
+/* $NetBSD: udf_create.c,v 1.20 2013/08/05 17:12:04 joerg Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -25,11 +25,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
#include <sys/cdefs.h>
-#ifndef lint
-__RCSID("$NetBSD: udf_create.c,v 1.19 2013/08/05 16:44:58 reinoud Exp $");
-#endif /* not lint */
+__RCSID("$NetBSD: udf_create.c,v 1.20 2013/08/05 17:12:04 joerg Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -76,9 +77,15 @@
context.volset_name = NULL;
context.fileset_name = NULL;
+#ifdef __NetBSD_Version__
context.app_name = "*NetBSD newfs";
context.app_version_main = __NetBSD_Version__ / 100000000;
context.app_version_sub = (__NetBSD_Version__ / 1000000) % 100;
+#else
+ context.app_name = "*NetBSD makefs";
+ context.app_version_main = 0;
+ context.app_version_sub = 0;
+#endif
context.impl_name = "*NetBSD kernel UDF";
context.vds_seq = 0; /* first one starts with zero */
@@ -1794,7 +1801,11 @@
/* set attributes */
if (st) {
+#if !HAVE_NBTOOL_CONFIG_H
udf_set_timestamp(&birthtime, st->st_birthtime);
+#else
+ udf_set_timestamp(&birthtime, 0);
+#endif
udf_set_timestamp(&fe->atime, st->st_atime);
udf_set_timestamp(&fe->attrtime, st->st_ctime);
udf_set_timestamp(&fe->mtime, st->st_mtime);
@@ -1891,7 +1902,11 @@
/* set attributes */
if (st) {
+#if !HAVE_NBTOOL_CONFIG_H
udf_set_timestamp(&efe->ctime, st->st_birthtime);
+#else
+ udf_set_timestamp(&efe->ctime, 0);
+#endif
udf_set_timestamp(&efe->atime, st->st_atime);
udf_set_timestamp(&efe->attrtime, st->st_ctime);
udf_set_timestamp(&efe->mtime, st->st_mtime);
diff -r dc2b5817744e -r d9142d80ac12 sbin/newfs_udf/udf_create.h
--- a/sbin/newfs_udf/udf_create.h Mon Aug 05 17:02:54 2013 +0000
+++ b/sbin/newfs_udf/udf_create.h Mon Aug 05 17:12:04 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.h,v 1.4 2013/08/05 14:11:30 reinoud Exp $ */
+/* $NetBSD: udf_create.h,v 1.5 2013/08/05 17:12:04 joerg Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -31,7 +31,11 @@
#include <sys/types.h>
#include <sys/stat.h>
+#if !HAVE_NBTOOL_CONFIG_H
#include <fs/udf/ecma167-udf.h>
+#else
+#include "../../sys/fs/udf/ecma167-udf.h"
+#endif
#include "udf_bswap.h"
#include "udf_osta.h"
diff -r dc2b5817744e -r d9142d80ac12 sbin/newfs_udf/udf_write.c
--- a/sbin/newfs_udf/udf_write.c Mon Aug 05 17:02:54 2013 +0000
+++ b/sbin/newfs_udf/udf_write.c Mon Aug 05 17:12:04 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_write.c,v 1.4 2013/08/05 16:44:58 reinoud Exp $ */
+/* $NetBSD: udf_write.c,v 1.5 2013/08/05 17:12:04 joerg Exp $ */
/*
* Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -25,11 +25,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
#include <sys/cdefs.h>
-#ifndef lint
-__RCSID("$NetBSD: udf_write.c,v 1.4 2013/08/05 16:44:58 reinoud Exp $");
-#endif /* not lint */
+__RCSID("$NetBSD: udf_write.c,v 1.5 2013/08/05 17:12:04 joerg Exp $");
#define _EXPOSE_MMC
@@ -42,7 +43,9 @@
#include <err.h>
#include <sys/types.h>
#include <sys/param.h>
+#if !HAVE_NBTOOL_CONFIG_H
#include <sys/cdio.h>
+#endif
#include "udf_create.h"
#include "udf_write.h"
@@ -172,6 +175,7 @@
int
udf_derive_format(int req_enable, int req_disable, int force)
{
+#if !HAVE_NBTOOL_CONFIG_H
/* disc writability, formatted, appendable */
if ((mmc_discinfo.mmc_cur & MMC_CAP_RECORDABLE) == 0) {
(void)printf("Can't newfs readonly device\n");
@@ -195,8 +199,10 @@
return EROFS;
}
}
+#endif
/* determine UDF format */
+#if !HAVE_NBTOOL_CONFIG_H
format_flags = 0;
if (mmc_discinfo.mmc_cur & MMC_CAP_REWRITABLE) {
/* all rewritable media */
@@ -229,6 +235,13 @@
format_flags |= FORMAT_WORM;
}
}
+#else
+ format_flags = FORMAT_REWRITABLE;
+ if (context.min_udf >= 0x0250) {
+ /* standard dictates meta as default */
+ format_flags |= FORMAT_META;
+ }
+#endif
/* enable/disable requests */
if (req_disable & FORMAT_META) {
@@ -244,6 +257,7 @@
/* determine partition/media access type */
media_accesstype = UDF_ACCESSTYPE_NOT_SPECIFIED;
+#if !HAVE_NBTOOL_CONFIG_H
if (mmc_discinfo.mmc_cur & MMC_CAP_REWRITABLE) {
media_accesstype = UDF_ACCESSTYPE_OVERWRITABLE;
if (mmc_discinfo.mmc_cur & MMC_CAP_ERASABLE)
@@ -254,6 +268,9 @@
}
if (mmc_discinfo.mmc_cur & MMC_CAP_PSEUDOOVERWRITE)
media_accesstype = UDF_ACCESSTYPE_PSEUDO_OVERWITE;
+#else
+ media_accesstype = UDF_ACCESSTYPE_OVERWRITABLE;
+#endif
/* patch up media accesstype */
if (req_enable & FORMAT_READONLY) {
@@ -319,21 +336,30 @@
if (context.logvol_name == NULL)
context.logvol_name = strdup("anonymous");
if (context.primary_name == NULL) {
+#if !HAVE_NBTOOL_CONFIG_H
if (mmc_discinfo.disc_flags & MMC_DFLAGS_DISCIDVALID) {
primary_nr = mmc_discinfo.disc_id;
} else {
primary_nr = (uint32_t) random();
}
+#else
+ primary_nr = (uint32_t) random();
+#endif
context.primary_name = calloc(32, 1);
sprintf(context.primary_name, "%08"PRIx32, primary_nr);
}
if (context.volset_name == NULL) {
+#if !HAVE_NBTOOL_CONFIG_H
if (mmc_discinfo.disc_flags & MMC_DFLAGS_BARCODEVALID) {
volset_nr = mmc_discinfo.disc_barcode;
} else {
volset_nr = (uint32_t) random();
volset_nr |= ((uint64_t) random()) << 32;
}
+#else
+ volset_nr = (uint32_t) random();
+ volset_nr |= ((uint64_t) random()) << 32;
+#endif
context.volset_name = calloc(128,1);
sprintf(context.volset_name, "%016"PRIx64, volset_nr);
}
@@ -441,7 +467,11 @@
{
union dscrptr *zero_dscr;
union dscrptr *dscr;
+#if !HAVE_NBTOOL_CONFIG_H
struct mmc_trackinfo ti;
+#else
+ extern off_t sectors;
+#endif
uint32_t sparable_blocks;
uint32_t sector_size, blockingnr;
uint32_t cnt, loc, len;
@@ -449,22 +479,29 @@
int error, integrity_type;
int data_part, metadata_part;
+#if !HAVE_NBTOOL_CONFIG_H
/* init */
sector_size = mmc_discinfo.sector_size;
/* determine span/size */
ti.tracknr = mmc_discinfo.first_track_last_session;
error = udf_update_trackinfo(&mmc_discinfo, &ti);
+#else
+ sector_size = 2048;
+#endif
if (error)
return error;
+#if !HAVE_NBTOOL_CONFIG_H
if (mmc_discinfo.sector_size < context.sector_size) {
fprintf(stderr, "Impossible to format: sectorsize too small\n");
return EIO;
}
+#endif
context.sector_size = sector_size;
/* determine blockingnr */
+#if !HAVE_NBTOOL_CONFIG_H
blockingnr = ti.packet_size;
if (blockingnr <= 1) {
/* paranoia on blockingnr */
@@ -491,7 +528,6 @@
default:
break;
}
-
}
if (blockingnr <= 0) {
printf("Can't fixup blockingnumber for device "
@@ -518,6 +554,17 @@
ti.track_start, mmc_discinfo.last_possible_lba,
context.sector_size, blockingnr, sparable_blocks,
meta_fract);
+#else
+ blockingnr = 32;
+ wrtrack_skew = 0;
+ sparable_blocks = 32;
+
+ error = udf_calculate_disc_layout(format_flags, context.min_udf,
+ wrtrack_skew,
+ 0, sectors - 1,
+ context.sector_size, blockingnr, sparable_blocks,
+ meta_fract);
+#endif
/* cache partition for we need it often */
data_part = context.data_part;
@@ -549,7 +596,11 @@
if ((zero_dscr = calloc(1, context.sector_size)) == NULL)
return ENOMEM;
+#if !HAVE_NBTOOL_CONFIG_H
loc = (format_flags & FORMAT_TRACK512) ? layout.vds1 : ti.track_start;
Home |
Main Index |
Thread Index |
Old Index