Date: Tue, 5 Jan 1999 13:41:07 +0100 (MET) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: ken@plutotech.com (Kenneth D. Merry) Cc: mike@smith.net.au, committers@FreeBSD.ORG Subject: Re: proposed atapi-cd patch Message-ID: <199901051241.NAA02615@labinfo.iet.unipi.it> In-Reply-To: <199901042346.QAA60358@panzer.plutotech.com> from "Kenneth D. Merry" at Jan 4, 99 04:46:05 pm
next in thread | previous in thread | raw e-mail | index | archive | help
Second attempt, more complete and addressing people's objection. * a new ioctl, CDIOCSETSTARTINGLBA, is added to sys/sys/cdio.h (one line). The various *_cd.c need a new state variable and about 6 lines of code to handle it. * mount_cd9660 has a new option, -t NN to select the track to mount. This is negated and passed to the kernel mount routine in args.ssector; * sys/isofs/cd9660/cd9660_vfsops.c detects the negative ssector, reads from the TOC of the disk the corresponding starting sector, and calls CDIOCSETSTARTINGLBA. Tried, seems to work fine and without disgusting hacks on minor numbers. Any taker for the 6 lines for CAM ? thanks luigi Index: sys/sys/cdio.h =================================================================== RCS file: /home/ncvs/src/sys/sys/cdio.h,v retrieving revision 1.19 diff -u -r1.19 cdio.h --- cdio.h 1998/09/08 20:57:47 1.19 +++ cdio.h 1999/01/05 13:24:21 @@ -282,5 +282,6 @@ }; #define CDIOCREADAUDIO _IOWR('c',31,struct ioc_read_audio) +#define CDIOCSETSTARTINGLBA _IOWR('c',32, int) #endif /* !_SYS_CDIO_H_ */ Index: sys/isofs/cd9660/cd9660_vfsops.c =================================================================== RCS file: /home/ncvs/src/sys/isofs/cd9660/cd9660_vfsops.c,v retrieving revision 1.46 diff -u -r1.46 cd9660_vfsops.c --- cd9660_vfsops.c 1998/12/06 11:36:24 1.46 +++ cd9660_vfsops.c 1999/01/05 13:22:35 @@ -141,6 +141,41 @@ return ntohl(t.entry.addr.lba); } +/* + * Sets the starting lba for the device. Used to mount the i-th track + * in multi-data track CDs + */ +static int +set_starting_lba(dev_t dev, struct proc *p, int track) +{ + struct ioc_toc_header h; + struct ioc_read_toc_single_entry t; + int i; + struct cdevsw *bd; + d_ioctl_t *ioctlp; + + bd = bdevsw[major(dev)]; + ioctlp = bd->d_ioctl; + if (ioctlp == NULL) + return 0; + + if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, p) != 0) + return 0; + + if (track > h.ending_track) + return 0 ; /* invalid track */ + t.address_format = CD_LBA_FORMAT; + t.track = track; + if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, p) != 0) + return 0; + if ((t.entry.control & 4) == 0) + return 0 ; /* not a data track */ + i = ntohl(t.entry.addr.lba) ; + if (ioctlp(dev, CDIOCSETSTARTINGLBA, (caddr_t)&i, FWRITE, p) != 0) + return 0; + return i ; +} + #ifndef VFS_LKM /* mount root makes no sense to an LKM */ static int iso_mountroot __P((struct mount *mp, struct proc *p)); @@ -326,6 +361,10 @@ */ iso_bsize = ISO_DEFAULT_BLOCK_SIZE; + if (argp->ssector) { + set_starting_lba(dev, p, -argp->ssector); + argp->ssector = 0 ; + } for (iso_blknum = 16 + argp->ssector; iso_blknum < 100 + argp->ssector; iso_blknum++) { Index: sbin/mount_cd9660/mount_cd9660.c =================================================================== RCS file: /home/ncvs/src/sbin/mount_cd9660/mount_cd9660.c,v retrieving revision 1.12 diff -u -r1.12 mount_cd9660.c --- mount_cd9660.c 1997/04/29 15:56:40 1.12 +++ mount_cd9660.c 1999/01/05 13:26:47 @@ -79,6 +79,7 @@ int get_ssector(const char *dev); void usage(void); +#define INVALID_SSECTOR -1234 int main(int argc, char **argv) { @@ -90,8 +91,8 @@ mntflags = opts = verbose = 0; memset(&args, 0, sizeof args); - args.ssector = -1; - while ((ch = getopt(argc, argv, "ego:rs:v")) != -1) + args.ssector = INVALID_SSECTOR ; + while ((ch = getopt(argc, argv, "ego:rs:t:v")) != -1) switch (ch) { case 'e': opts |= ISOFSMNT_EXTATT; @@ -108,6 +109,9 @@ case 's': args.ssector = atoi(optarg); break; + case 't': /* track number */ + args.ssector = - atoi(optarg); + break; case 'v': verbose++; break; @@ -134,7 +138,7 @@ args.export.ex_root = DEFAULT_ROOTUID; args.flags = opts; - if (args.ssector == -1) { + if (args.ssector == INVALID_SSECTOR) { /* * The start of the session has not been specified on * the command line. If we can successfully read the Index: sys/i386/isa/atapi-cd.c =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/atapi-cd.c,v retrieving revision 1.6 diff -u -r1.6 atapi-cd.c --- atapi-cd.c 1998/12/07 21:58:20 1.6 +++ atapi-cd.c 1999/01/05 13:24:05 @@ -123,6 +123,7 @@ ptr->flags = F_MEDIA_CHANGED; ptr->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); ptr->block_size = 2048; + ptr->starting_lba = 0 ; ptr->refcnt = 0; ptr->slot = -1; ptr->changer_info = NULL; @@ -409,6 +410,7 @@ } } } + cdp->starting_lba = 0 ; return 0; } @@ -527,7 +529,8 @@ #ifdef NOTYET lba = bp->b_offset / cdp->block_size; #else - lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); + lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE) + + cdp->starting_lba ; #endif else lba = cdp->next_writeable_lba + (bp->b_offset / cdp->block_size); @@ -975,6 +978,10 @@ arg->patch[2], arg->patch[3]); } + case CDIOCSETSTARTINGLBA: + cdp->starting_lba = *(int *)addr; + return 0 ; + case CDIOCSETMONO: return acd_setchan(cdp, CHANNEL_0|CHANNEL_1, CHANNEL_0|CHANNEL_1, 0, 0); Index: sys/i386/isa/atapi-cd.h =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/atapi-cd.h,v retrieving revision 1.2 diff -u -r1.2 atapi-cd.h --- atapi-cd.h 1998/10/15 08:11:55 1.2 +++ atapi-cd.h 1999/01/04 13:29:07 @@ -345,6 +345,8 @@ u_char speed; /* Select drive speed */ u_int next_writeable_lba; /* Next writable position */ struct wormio_prepare_track preptrack; /* Scratch region */ + + u_int starting_lba; /* for multitrack */ #ifdef DEVFS void *ra_devfs_token; void *rc_devfs_token; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901051241.NAA02615>