[patch] select session on multisession CD (2.1.132 isofs)

Grisha Vasilyev (acid@pe.ti.chernigov.ua)
Tue, 29 Dec 1998 13:29:53 +0000 (Local time zone must be set--see zic manual pagacid@pe.ti.chernigov.ua


Hello everyone !

This little patch makes possible select session on multisession CD by
arguments to "mount" command:

mount -o session=<n> /dev/cdrom /mnt/cdrom -tiso9660
or
mount -o sbsector=<xxx> /dev/cdrom /mnt/cdrom -tiso9660

patch originaly written by Vitaly E. Lavrov <lve@lve.cit.aanet.ru>

p.s. this is my first posting, so please don't blame me :)

--- linux/fs/isofs/inode.c.orig Fri Sep 25 23:27:13 1998
+++ linux/fs/isofs/inode.c Tue Dec 29 12:30:55 1998
@@ -126,6 +126,9 @@
uid_t uid;
char *iocharset;
unsigned char utf8;
+ /* LVE */
+ s32 session;
+ s32 sbsector;
};

/*
@@ -294,6 +297,8 @@
popt->uid = 0;
popt->iocharset = NULL;
popt->utf8 = 0;
+ popt->session=-1;
+ popt->sbsector=-1;
if (!options) return 1;
for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
if (strncmp(this_char,"norock",6) == 0) {
@@ -337,6 +342,18 @@
else if (!strcmp(value,"acorn")) popt->map = 'a';
else return 0;
}
+ if (!strcmp(this_char,"session") && value) {
+ char * vpnt = value;
+ unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
+ if(ivalue < 0 || ivalue >99) return 0;
+ popt->session=ivalue+1;
+ }
+ if (!strcmp(this_char,"sbsector") && value) {
+ char * vpnt = value;
+ unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
+ if(ivalue < 0 || ivalue >660*512) return 0;
+ popt->sbsector=ivalue;
+ }
else if (!strcmp(this_char,"check") && value) {
if (value[0] && !value[1] && strchr("rs",*value))
popt->check = *value;
@@ -404,7 +421,7 @@
*/
#define WE_OBEY_THE_WRITTEN_STANDARDS 1

-static unsigned int isofs_get_last_session(kdev_t dev)
+static unsigned int isofs_get_last_session(kdev_t dev,s32 session )
{
struct cdrom_multisession ms_info;
unsigned int vol_desc_start;
@@ -423,11 +440,26 @@
inode_fake.i_rdev=dev;
ms_info.addr_format=CDROM_LBA;
set_fs(KERNEL_DS);
+ if(session >= 0 && session <= 99) {
+ struct cdrom_tocentry Te;
+ Te.cdte_track=session;
+ Te.cdte_format=CDROM_LBA;
+ i=get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
+ NULL,
+ CDROMREADTOCENTRY,
+ (unsigned long) &Te);
+ set_fs(old_fs);
+ if(!i) printk(KERN_ERR"Session %d start %d type %d\n",session,Te.cdte_addr.lba,Te.cdte_ctrl&CDROM_DATA_TRACK);
+ if(i || (Te.cdte_ctrl&CDROM_DATA_TRACK) != 4)
+ printk(KERN_ERR"Invalid session number or type of track\n");
+ else return Te.cdte_addr.lba;
+ }
i=get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
NULL,
CDROMMULTISESSION,
(unsigned long) &ms_info);
set_fs(old_fs);
+ if(session > 0) printk(KERN_ERR"Invalid session number\n");
#if 0
printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i);
if (i==0)
@@ -521,7 +553,8 @@

s->u.isofs_sb.s_high_sierra = high_sierra = 0; /* default is iso9660 */

- vol_desc_start = isofs_get_last_session(dev);
+ vol_desc_start = (opt.sbsector != -1) ?
+ opt.sbsector : isofs_get_last_session(dev,opt.session);

for (iso_blknum = vol_desc_start+16;
iso_blknum < vol_desc_start+100; iso_blknum++)
--- linux/Documentation/filesystems/isofs.txt.orig Wed Jun 24 21:30:07 1998
+++ linux/Documentation/filesystems/isofs.txt Tue Dec 29 12:44:14 1998
@@ -27,3 +27,5 @@
nojoliet Ignore Joliet extensions if they are present.
norock Ignore Rock Ridge extensions if they are present.
unhide Show hidden files.
+ session=x Select number of session on multisession CD
+ sbsector=xxx Set session offset=xxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/