Module Name: src
Committed By: joerg
Date: Mon Aug 5 17:12:04 UTC 2013
Modified Files:
src/sbin/newfs_udf: newfs_udf.h udf_create.c udf_create.h udf_write.c
udf_write.h
src/usr.sbin/makefs: udf.c
Log Message:
Allow building UDF parts of makefs on !NetBSD.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/newfs_udf/newfs_udf.h
cvs rdiff -u -r1.19 -r1.20 src/sbin/newfs_udf/udf_create.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/newfs_udf/udf_create.h \
src/sbin/newfs_udf/udf_write.c
cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_udf/udf_write.h
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/udf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/newfs_udf/newfs_udf.h
diff -u src/sbin/newfs_udf/newfs_udf.h:1.1 src/sbin/newfs_udf/newfs_udf.h:1.2
--- src/sbin/newfs_udf/newfs_udf.h:1.1 Thu Jul 18 12:44:21 2013
+++ src/sbin/newfs_udf/newfs_udf.h Mon Aug 5 17:12:04 2013
@@ -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 @@ struct udf_disclayout layout;
/* 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);
Index: src/sbin/newfs_udf/udf_create.c
diff -u src/sbin/newfs_udf/udf_create.c:1.19 src/sbin/newfs_udf/udf_create.c:1.20
--- src/sbin/newfs_udf/udf_create.c:1.19 Mon Aug 5 16:44:58 2013
+++ src/sbin/newfs_udf/udf_create.c Mon Aug 5 17:12:04 2013
@@ -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 @@ udf_init_create_context(void)
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 @@ udf_create_new_fe(struct file_entry **fe
/* 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 @@ udf_create_new_efe(struct extfile_entry
/* 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);
Index: src/sbin/newfs_udf/udf_create.h
diff -u src/sbin/newfs_udf/udf_create.h:1.4 src/sbin/newfs_udf/udf_create.h:1.5
--- src/sbin/newfs_udf/udf_create.h:1.4 Mon Aug 5 14:11:30 2013
+++ src/sbin/newfs_udf/udf_create.h Mon Aug 5 17:12:04 2013
@@ -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"
Index: src/sbin/newfs_udf/udf_write.c
diff -u src/sbin/newfs_udf/udf_write.c:1.4 src/sbin/newfs_udf/udf_write.c:1.5
--- src/sbin/newfs_udf/udf_write.c:1.4 Mon Aug 5 16:44:58 2013
+++ src/sbin/newfs_udf/udf_write.c Mon Aug 5 17:12:04 2013
@@ -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 @@ __RCSID("$NetBSD: udf_write.c,v 1.4 2013
#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 @@ udf_data_alloc(int nblk, struct long_ad
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 @@ udf_derive_format(int req_enable, int re
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 @@ udf_derive_format(int req_enable, int re
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 @@ udf_derive_format(int req_enable, int re
/* 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 @@ udf_derive_format(int req_enable, int re
}
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 @@ udf_proces_names(void)
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 @@ udf_do_newfs_prefix(void)
{
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 @@ udf_do_newfs_prefix(void)
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 @@ udf_do_newfs_prefix(void)
default:
break;
}
-
}
if (blockingnr <= 0) {
printf("Can't fixup blockingnumber for device "
@@ -518,6 +554,17 @@ udf_do_newfs_prefix(void)
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 @@ udf_do_newfs_prefix(void)
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;
+#else
+ loc = (format_flags & FORMAT_TRACK512) ? layout.vds1 : 0;
+#endif
for (; loc < layout.part_start_lba; loc++) {
if ((error = udf_write_sector(zero_dscr, loc))) {
free(zero_dscr);
Index: src/sbin/newfs_udf/udf_write.h
diff -u src/sbin/newfs_udf/udf_write.h:1.2 src/sbin/newfs_udf/udf_write.h:1.3
--- src/sbin/newfs_udf/udf_write.h:1.2 Mon Aug 5 14:11:30 2013
+++ src/sbin/newfs_udf/udf_write.h Mon Aug 5 17:12:04 2013
@@ -28,7 +28,9 @@
#define _FS_UDF_UDF_WRITE_H_
#include "udf_create.h"
+#if !HAVE_NBTOOL_CONFIG_H
#include <sys/cdio.h>
+#endif
/* prototypes */
Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.2 src/usr.sbin/makefs/udf.c:1.3
--- src/usr.sbin/makefs/udf.c:1.2 Mon Aug 5 16:43:46 2013
+++ src/usr.sbin/makefs/udf.c Mon Aug 5 17:12:04 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.2 2013/08/05 16:43:46 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.3 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.c,v 1.2 2013/08/05 16:43:46 reinoud Exp $");
-#endif /* not lint */
+__RCSID("$NetBSD: udf.c,v 1.3 2013/08/05 17:12:04 joerg Exp $");
#define _EXPOSE_MMC
@@ -44,7 +45,9 @@ __RCSID("$NetBSD: udf.c,v 1.2 2013/08/05
#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>
@@ -63,7 +66,9 @@ __RCSID("$NetBSD: udf.c,v 1.2 2013/08/05
/* 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 */
@@ -150,6 +155,7 @@ udf_dump_discinfo(struct mmc_discinfo *d
/* --------------------------------------------------------------------- */
+#if !HAVE_NBTOOL_CONFIG_H
static int
udf_emulate_discinfo(fsinfo_t *fsopts, struct mmc_discinfo *di,
int mmc_emuprofile)
@@ -260,7 +266,16 @@ udf_update_trackinfo(struct mmc_discinfo
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 }
@@ -879,7 +894,7 @@ udf_copy_file(struct stat *st, char *pat
fnode = cur->inode;
- f = open(path, O_RDONLY, 0, 0);
+ f = open(path, O_RDONLY);
if (f < 0) {
warn("Can't open file %s for reading", cur->name);
return errno;
@@ -1169,7 +1184,11 @@ udf_makefs(const char *image, const char
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;
@@ -1212,7 +1231,11 @@ udf_makefs(const char *image, const char
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();