socsvn commit: r238140 - soc2012/oleksandr/udf-head/sys/fs/udf2
oleksandr at FreeBSD.org
oleksandr at FreeBSD.org
Fri Jun 22 13:31:26 UTC 2012
Author: oleksandr
Date: Fri Jun 22 13:31:23 2012
New Revision: 238140
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238140
Log:
Change implementation of function udf_read_anchor, add correct sectors number and some clean code
Modified:
soc2012/oleksandr/udf-head/sys/fs/udf2/udf_readwrite.c
soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c
soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.h
soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vfsops.c
Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_readwrite.c
==============================================================================
--- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_readwrite.c Fri Jun 22 12:15:38 2012 (r238139)
+++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_readwrite.c Fri Jun 22 13:31:23 2012 (r238140)
@@ -337,7 +337,7 @@
struct vnode *devvp = ump->devvp;
sector_size = ump->sector_size;
- blks = sector_size / DEV_BSIZE;
+ blks = btodb(sector_size);
while (sectors > 0 && error == 0) {
if ((error = bread(devvp, start*blks, sector_size, NOCRED,
Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c
==============================================================================
--- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Fri Jun 22 12:15:38 2012 (r238139)
+++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Fri Jun 22 13:31:23 2012 (r238140)
@@ -25,6 +25,8 @@
*/
+#include <machine/_inttypes.h>
+#include <sys/cdefs.h>
#include <sys/cdefs.h>
#include <sys/endian.h>
#include <sys/param.h>
@@ -53,7 +55,8 @@
extern int (**udf_vnodeop_p)(void *);
/* --------------------------------------------------------------------- */
-#if 0
+
+//#ifdef DEBUG
#if 1
#if 0
@@ -110,7 +113,8 @@
printf("\tfst on last ses %d\n", di->first_track_last_session);
printf("\tlst on last ses %d\n", di->last_track_last_session);
printf("\tlink block penalty %d\n", di->link_block_penalty);
- snprintb(bits, sizeof(bits), MMC_DFLAGS_FLAGBITS, di->disc_flags);
+/* TODO: find analog function in Freebsd */
+// snprintb(bits, sizeof(bits), MMC_DFLAGS_FLAGBITS, di->disc_flags);
printf("\tdisc flags %s\n", bits);
printf("\tdisc id %x\n", di->disc_id);
printf("\tdisc barcode %"PRIx64"\n", di->disc_barcode);
@@ -118,12 +122,12 @@
printf("\tnum sessions %d\n", di->num_sessions);
printf("\tnum tracks %d\n", di->num_tracks);
- snprintb(bits, sizeof(bits), MMC_CAP_FLAGBITS, di->mmc_cur);
+// snprintb(bits, sizeof(bits), MMC_CAP_FLAGBITS, di->mmc_cur);
printf("\tcapabilities cur %s\n", bits);
- snprintb(bits, sizeof(bits), MMC_CAP_FLAGBITS, di->mmc_cap);
+// snprintb(bits, sizeof(bits), MMC_CAP_FLAGBITS, di->mmc_cap);
printf("\tcapabilities cap %s\n", bits);
}
-
+#if 0
static void
udf_dump_trackinfo(struct mmc_trackinfo *trackinfo)
{
@@ -136,7 +140,7 @@
printf("\tsessionnr %d\n", trackinfo->sessionnr);
printf("\ttrack mode %d\n", trackinfo->track_mode);
printf("\tdata mode %d\n", trackinfo->data_mode);
- snprintb(bits, sizeof(bits), MMC_TRACKINFO_FLAGBITS, trackinfo->flags);
+// snprintb(bits, sizeof(bits), MMC_TRACKINFO_FLAGBITS, trackinfo->flags);
printf("\tflags %s\n", bits);
printf("\ttrack start %d\n", trackinfo->track_start);
@@ -146,7 +150,7 @@
printf("\ttrack size %d\n", trackinfo->track_size);
printf("\tlast recorded block %d\n", trackinfo->last_recorded);
}
-
+#endif
#else
#define udf_dump_discinfo(a);
#define udf_dump_trackinfo(a);
@@ -157,29 +161,30 @@
/* not called often */
int
-udf_update_discinfo(struct udf_mount *ump)
+udf_update_discinfo(struct udf_mount *ump, uint64_t psize, uint32_t secsize)
{
struct vnode *devvp = ump->devvp;
- struct partinfo dpart;
+ struct thread *td;
struct mmc_discinfo *di;
int error;
DPRINTF(VOLUMES, ("read/update disc info\n"));
di = &ump->discinfo;
+ td = curthread;
memset(di, 0, sizeof(struct mmc_discinfo));
/* check if we're on a MMC capable device, i.e. CD/DVD */
- error = VOP_IOCTL(devvp, MMCGETDISCINFO, di, FKIOCTL, NOCRED);
+ error = VOP_IOCTL(devvp, MMCGETDISCINFO, di, FKIOCTL, NOCRED, td);
if (error == 0) {
udf_dump_discinfo(ump);
return 0;
}
-
+#if 0
/* disc partition support */
- error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED);
+ error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED, td);
if (error)
return ENODEV;
-
+#endif
/* set up a disc info profile for partitions */
di->mmc_profile = 0x01; /* disc type */
di->mmc_class = MMC_CLASS_DISC;
@@ -194,8 +199,8 @@
di->disc_flags = MMC_DFLAGS_UNRESTRICTED;
/* TODO problem with last_possible_lba on resizable VND; request */
- di->last_possible_lba = dpart.part->p_size;
- di->sector_size = dpart.disklab->d_secsize;
+ di->last_possible_lba = psize;
+ di->sector_size = secsize;
di->num_sessions = 1;
di->num_tracks = 1;
@@ -213,14 +218,16 @@
{
struct vnode *devvp = ump->devvp;
struct mmc_discinfo *di = &ump->discinfo;
+ struct thread *td;
int error, class;
DPRINTF(VOLUMES, ("read track info\n"));
+ td = curthread;
class = di->mmc_class;
if (class != MMC_CLASS_DISC) {
/* tracknr specified in struct ti */
- error = VOP_IOCTL(devvp, MMCGETTRACKINFO, ti, FKIOCTL, NOCRED);
+ error = VOP_IOCTL(devvp, MMCGETTRACKINFO, ti, FKIOCTL, NOCRED, td);
return error;
}
@@ -247,7 +254,7 @@
return 0;
}
-
+#if 0
int
udf_setup_writeparams(struct udf_mount *ump)
{
@@ -315,6 +322,7 @@
/* --------------------------------------------------------------------- */
+#endif
/* track/session searching for mounting */
int
udf_search_tracks(struct udf_mount *ump, struct udf_args *args,
@@ -383,10 +391,11 @@
return EINVAL;
}
- assert(*last_tracknr >= *first_tracknr);
+/* assert(*last_tracknr >= *first_tracknr); */
return 0;
}
+#if 0
/*
* NOTE: this is the only routine in this file that directly peeks into the
* metadata file but since its at a larval state of the mount it can't hurt.
@@ -933,14 +942,11 @@
int
udf_read_anchors(struct udf_mount *ump)
{
+#if 0
struct anchor_vdp **anchorsp;
int error, anch, ok, first_anchor;
uint32_t positions[4], track_start, track_end;
-// struct udf_args *args = &ump->mount_args;
-// struct mmc_trackinfo first_track;
-// struct mmc_trackinfo second_track;
-
track_start = ump->session_start;
track_end = ump->session_end;
@@ -972,7 +978,7 @@
}
return ok;
-#if 0
+#endif
struct udf_args *args = &ump->mount_args;
struct mmc_trackinfo first_track;
struct mmc_trackinfo second_track;
@@ -1033,7 +1039,7 @@
ump->packet_size = MAXPHYS / ump->discinfo.sector_size;
ump->packet_size = MIN(ump->packet_size, 64);
}
- KASSERT(ump->packet_size >= 1);
+ /*KASSERT(ump->packet_size >= 1); */
/* read anchors start+256, start+512, end-256, end */
positions[0] = track_start+256;
@@ -1053,7 +1059,12 @@
ok++;
}
}
-#endif
+
+ /* VATs are only recorded on sequential media, but initialise */
+ ump->first_possible_vat_location = track_start + 2;
+ ump->last_possible_vat_location = track_end + last_track.packet_size;
+
+ return ok;
}
/* --------------------------------------------------------------------- */
Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.h
==============================================================================
--- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.h Fri Jun 22 12:15:38 2012 (r238139)
+++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.h Fri Jun 22 13:31:23 2012 (r238140)
@@ -33,10 +33,10 @@
/* device information updating */
-//int udf_update_trackinfo(struct udf_mount *ump, struct mmc_trackinfo *trackinfo);
-//int udf_update_discinfo(struct udf_mount *ump);
-//int udf_search_tracks(struct udf_mount *ump, struct udf_args *args,
-// int *first_tracknr, int *last_tracknr);
+int udf_update_trackinfo(struct udf_mount *ump, struct mmc_trackinfo *trackinfo);
+int udf_update_discinfo(struct udf_mount *ump, uint64_t psize, uint32_t secsize);
+int udf_search_tracks(struct udf_mount *ump, struct udf_args *args,
+ int *first_tracknr, int *last_tracknr);
//int udf_search_writing_tracks(struct udf_mount *ump);
//int udf_setup_writeparams(struct udf_mount *ump);
//int udf_synchronise_caches(struct udf_mount *ump);
Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vfsops.c
==============================================================================
--- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vfsops.c Fri Jun 22 12:15:38 2012 (r238139)
+++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vfsops.c Fri Jun 22 13:31:23 2012 (r238140)
@@ -187,10 +187,12 @@
struct thread *td;
struct vnode *devvp;
struct nameidata nd;
+ struct vfsoptlist *opts;
int error, len;
char *fspec;
td = curthread;
+ opts = mp->mnt_optnew;
DPRINTF(CALL, ("udf_mount called\n"));
/*
* Unconditionally mount as read-only.
@@ -209,7 +211,7 @@
return (0);
fspec = NULL;
- error = vfs_getopt(mp->mnt_optnew, "from", (void **)&fspec, &len);
+ error = vfs_getopt(opts, "from", (void **)&fspec, &len);
if (!error && fspec[len - 1] != '\0')
return (EINVAL);
@@ -384,19 +386,22 @@
static int
udf_mountfs(struct vnode *devvp, struct mount *mp)
{
+ struct udf_args *args = NULL;
struct g_consumer *cp;
struct cdev *dev;
struct udf_mount *ump = NULL;
+ struct vfsoptlist *opts;
int num_anchors, error, len, *udf_flags;
- uint32_t bshift, logvol_integrity; /*lb_size,*/
+ uint32_t bshift, logvol_integrity, sector_size; /*lb_size,*/
char *cs_disk, *cs_local;
- void *optdata;
+// void *optdata;
#if 0
/* flush out any old buffers remaining from a previous use. */
if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)))
return error;
#endif
+ opts = mp->mnt_optnew;
/* Open a consumer. */
dev = devvp->v_rdev;
@@ -448,10 +453,13 @@
ump->dev = dev;
ump->geomcp = cp;
ump->bo = &devvp->v_bufobj;
+
+ /* set up arguments and device */
+// ump->mount_args = *args;
/* Load flags for later. Not sure what to use them for... */
udf_flags = NULL;
- error = vfs_getopt(mp->mnt_optnew, "flags", (void **)&udf_flags, &len);
+ error = vfs_getopt(opts, "flags", (void **)&udf_flags, &len);
if (error || len != sizeof(int))
return (EINVAL);
ump->flags = *udf_flags;
@@ -461,9 +469,9 @@
ump->anon_gid = 0;
ump->nobody_uid = -1;
ump->nobody_gid = -1;
-
+#if 0
optdata = NULL;
- error = vfs_getopt(mp->mnt_optnew, "first_trackblank", &optdata, &len);
+ error = vfs_getopt(opts, "first_trackblank", &optdata, &len);
if (error || len != sizeof(uint32_t)) {
error = EINVAL;
goto fail;
@@ -471,7 +479,7 @@
ump->first_trackblank = *(uint32_t *)optdata;
optdata = NULL;
- error = vfs_getopt(mp->mnt_optnew, "session_start_addr", &optdata, &len);
+ error = vfs_getopt(opts, "session_start_addr", &optdata, &len);
if (error || len != sizeof(uint32_t)) {
error = EINVAL;
goto fail;
@@ -479,7 +487,7 @@
ump->session_start = *(uint32_t *)optdata;
optdata = NULL;
- error = vfs_getopt(mp->mnt_optnew, "session_end_addr", &optdata, &len);
+ error = vfs_getopt(opts, "session_end_addr", &optdata, &len);
if (error || len != sizeof(uint32_t)) {
error = EINVAL;
goto fail;
@@ -487,12 +495,12 @@
ump->session_end = *(uint32_t *)optdata;
ump->last_possible_vat_location = ump->session_end;
-
+#endif
if (ump->flags & UDFMNT_KICONV && udf2_iconv) {
cs_disk = "UTF-16BE";
cs_local = NULL;
- error = vfs_getopt(mp->mnt_optnew, "cs_local", (void **)&cs_local, &len);
+ error = vfs_getopt(opts, "cs_local", (void **)&cs_local, &len);
if (error != 0 || cs_local[len-1] != '\0') {
error = EINVAL;
goto fail;
@@ -503,27 +511,31 @@
udf2_iconv->open(cs_disk, cs_local, &ump->iconv_l2d);
#endif
}
+
+ if ((error = udf_update_discinfo(ump, cp->provider->sectorsize, cp->provider->mediasize))) {
+ printf("UDF mount: error inspecting fs node\n");
+ return error;
+ }
/* inspect sector size */
ump->sector_size = cp->provider->sectorsize;
-
+ sector_size = ump->discinfo.sector_size;
bshift = 1;
- while ((1 << bshift) < ump->sector_size)
+ while ((1 << bshift) < sector_size)
bshift++;
- if ((1 << bshift) != ump->sector_size) {
+ if ((1 << bshift) != sector_size) {
printf("UDF mount: "
"hit implementation fence on sector size\n");
return EIO;
}
/* temporary check to overcome sectorsize >= 8192 bytes panic */
- if (ump->sector_size >= 8192) {
+ if (sector_size >= 8192) {
printf("UDF mount: "
"hit implementation limit, sectorsize to big\n");
return EIO;
}
-#if 0
/*
* Inspect if we're asked to mount read-write on a non recordable or
* closed sequential disc.
@@ -545,13 +557,14 @@
*/
}
/* double check if we're not mounting a pervious session RW */
+//#if 0
if (args->sessionnr != 0) {
printf("UDF mount: updating a previous session "
"not yet allowed\n");
return EROFS;
}
+//#endif
}
-#endif
#if 0
/* initialise bootstrap disc strategy */
More information about the svn-soc-all
mailing list