From e11439b493f7f17321c06b3e6ea713591ee1ac49 Mon Sep 17 00:00:00 2001 From: Pedro Martelletto Date: Tue, 11 Jul 2006 16:24:10 +0000 Subject: Make the mounting process pass a hint to the kernel of where to find the VAT --- sbin/mount_udf/mount_udf.c | 31 ++++++++++++++++++++++++++++++- sys/isofs/udf/udf_extern.h | 4 ++-- sys/isofs/udf/udf_subr.c | 6 +++--- sys/isofs/udf/udf_vfsops.c | 11 +++++------ sys/sys/mount.h | 9 ++++----- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/sbin/mount_udf/mount_udf.c b/sbin/mount_udf/mount_udf.c index fca2e122101..813e1e5ca73 100644 --- a/sbin/mount_udf/mount_udf.c +++ b/sbin/mount_udf/mount_udf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_udf.c,v 1.2 2005/04/08 20:09:38 jaredy Exp $ */ +/* $OpenBSD: mount_udf.c,v 1.3 2006/07/11 16:24:09 pedro Exp $ */ /* * Copyright (c) 2005 Pedro Martelletto @@ -19,8 +19,12 @@ #include #include +#include +#include #include +#include +#include #include #include @@ -38,6 +42,30 @@ usage(void) exit(EXIT_FAILURE); } +/* Find out media's last block by looking at the LBA of the lead-out track. */ +u_int32_t +lastblock(char *dev) +{ + int fd, error; + struct ioc_read_toc_entry t; + struct cd_toc_entry te; + + fd = open(dev, O_RDONLY, 0); + if (fd < 0) + err(1, "open"); + + t.address_format = CD_LBA_FORMAT; + t.starting_track = CD_TRACK_LEADOUT; + t.data_len = sizeof(struct cd_toc_entry); + t.data = &te; + + error = ioctl(fd, CDIOREADTOCENTRIES, &t); + + close(fd); + + return (error == -1 ? 0 : te.addr.lba); +} + int main(int argc, char **argv) { @@ -61,6 +89,7 @@ main(int argc, char **argv) usage(); args.fspec = argv[0]; + args.lastblock = lastblock(argv[0]); if (realpath(argv[1], node) == NULL) err(1, "realpath %s", argv[1]); diff --git a/sys/isofs/udf/udf_extern.h b/sys/isofs/udf/udf_extern.h index 7950d658271..011f5cbbe8f 100644 --- a/sys/isofs/udf/udf_extern.h +++ b/sys/isofs/udf/udf_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_extern.h,v 1.6 2006/07/09 04:14:25 pedro Exp $ */ +/* $OpenBSD: udf_extern.h,v 1.7 2006/07/11 16:24:09 pedro Exp $ */ /* * Written by Pedro Martelletto in February 2005. @@ -9,7 +9,7 @@ * udf_subr.c */ int udf_rawnametounicode(u_int len, char *, unicode_t *); -int udf_vat_get(struct umount *); +int udf_vat_get(struct umount *, uint32_t); int udf_vat_map(struct umount *, uint32_t *); /* diff --git a/sys/isofs/udf/udf_subr.c b/sys/isofs/udf/udf_subr.c index cc58cd9fb51..d976a37fd8f 100644 --- a/sys/isofs/udf/udf_subr.c +++ b/sys/isofs/udf/udf_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_subr.c,v 1.9 2006/07/09 04:14:25 pedro Exp $ */ +/* $OpenBSD: udf_subr.c,v 1.10 2006/07/11 16:24:09 pedro Exp $ */ /* * Copyright (c) 2006, Miodrag Vallat @@ -183,13 +183,13 @@ out: /* Get a vnode for the Virtual Allocation Table (VAT) */ int -udf_vat_get(struct umount *ump) +udf_vat_get(struct umount *ump, uint32_t lb) { struct vnode *vp; struct unode *up; int error; - error = udf_vget(ump->um_mountp, ump->um_len - 3, &vp); + error = udf_vget(ump->um_mountp, lb - ump->um_start - 3, &vp); if (error) return (error); diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c index b69cce5b114..efd87e012f5 100644 --- a/sys/isofs/udf/udf_vfsops.c +++ b/sys/isofs/udf/udf_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_vfsops.c,v 1.19 2006/07/09 04:23:09 pedro Exp $ */ +/* $OpenBSD: udf_vfsops.c,v 1.20 2006/07/11 16:24:09 pedro Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -79,6 +79,7 @@ struct pool udf_ds_pool; int udf_find_partmaps(struct umount *, struct logvol_desc *); int udf_get_vpartmap(struct umount *, struct part_map_virt *); int udf_get_spartmap(struct umount *, struct part_map_spare *); +int udf_mountfs(struct vnode *, struct mount *, uint32_t, struct proc *); const struct vfsops udf_vfsops = { .vfs_fhtovp = udf_fhtovp, @@ -96,8 +97,6 @@ const struct vfsops udf_vfsops = { .vfs_checkexp = udf_checkexp, }; -int udf_mountfs(struct vnode *, struct mount *, struct proc *); - int udf_init(struct vfsconf *foo) { @@ -171,7 +170,7 @@ udf_mount(struct mount *mp, const char *path, void *data, } } - if ((error = udf_mountfs(devvp, mp, p))) { + if ((error = udf_mountfs(devvp, mp, args.lastblock, p))) { vrele(devvp); return (error); } @@ -213,7 +212,7 @@ udf_checktag(struct desc_tag *tag, uint16_t id) } int -udf_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p) +udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) { struct buf *bp = NULL; struct anchor_vdp avdp; @@ -335,7 +334,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p) /* Get the VAT, if needed */ if (ump->um_flags & UDF_MNT_FIND_VAT) { - error = udf_vat_get(ump); + error = udf_vat_get(ump, lb); if (error) goto bail; } diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 981bef28436..6acd3d1161c 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.73 2006/06/25 15:01:54 sturm Exp $ */ +/* $OpenBSD: mount.h,v 1.74 2006/07/11 16:24:09 pedro Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -252,11 +252,10 @@ struct ntfs_args { #define NTFS_MFLAG_CASEINS 0x00000001 #define NTFS_MFLAG_ALLNAMES 0x00000002 -/* - * Arguments to mount UDF filesystems. - */ +/* Arguments to mount UDF file systems */ struct udf_args { - char *fspec; /* block special device to mount */ + char *fspec; /* Block special device to mount */ + u_int32_t lastblock; /* Special device last block */ }; /* -- cgit v1.2.3