|
From: Jan-Benedict G. <jb...@us...> - 2004-09-20 05:39:19
|
Update of /cvsroot/linux-vax/kernel-2.5/fs/ods2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4263 Modified Files: CHANGES dir.c file.c inode.c ods2.h super.c util.c Log Message: - Typedef -> struct "downgrade". Index: util.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/util.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- util.c 19 Sep 2004 19:51:15 -0000 1.3 +++ util.c 20 Sep 2004 05:39:07 -0000 1.4 @@ -27,10 +27,11 @@ #include "tparse.h" -u64 div64(u64 a, u32 b0) { +u64 +div64 (u64 a, u32 b0) { u32 a1, a2; - u32 long res; - + u32 long res; /* FIXME: What?! */ + a1 = ((u32 *)&a)[0]; a2 = ((u32 *)&a)[1]; res = a1/b0 + (u64)a2 * (u64)(0xffffffff/b0) + a2 / b0 + (a2 * (0xffffffff % b0)) / b0; @@ -38,10 +39,12 @@ } -u32 vbn2lbn(struct super_block *sb, ODS2MAP *map, u32 vbn) { - int idx = 0; - u32 curvbn = 1; /* VBN is 1 based - not 0 */ - +u32 +vbn2lbn (struct super_block *sb, struct ods2map *map, u32 vbn) +{ + int idx = 0; + u32 curvbn = 1; /* VBN is 1 based - not 0 */ + while (map && map->s1[idx].cnt > 0 && curvbn < vbn && curvbn + map->s1[idx].cnt <= vbn) { curvbn += map->s1[idx].cnt; if (++idx > 15) { @@ -55,61 +58,64 @@ return 0; } - u32 ino2fhlbn (struct super_block *sb, u32 ino) { - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); if (ino < 17) { /* the first 16 file headers are located at known locations in INDEXF.SYS */ return le16_to_cpu(ods2p->hm2.hm2_w_ibmapsize) + le32_to_cpu(ods2p->hm2.hm2_l_ibmaplbn) + ino - 1; } else { - ODS2FH *ods2fhp = (ODS2FH *)ods2p->indexf->u.generic_ip; + struct ods2fh *ods2fhp = (struct ods2fh *) ods2p->indexf->u.generic_ip; return vbn2lbn(sb, ods2fhp->map, le16_to_cpu(ods2p->hm2.hm2_w_cluster) * 4 + le16_to_cpu(ods2p->hm2.hm2_w_ibmapsize) + ino); } + return 0; } /* - This function retreives all file mapping pointers and create a linked list so - VBN's can be translated to LBN's. - Note that this routine read ALL mapping pointers thus creating a catedral window - for the file. Should there be extension headers they are all read directly not - using iget to fetch them. -*/ - -ODS2MAP *getmap(struct super_block *sb, FH2DEF *fh2p) { - FM2DEF *fm2p = (FM2DEF *)((short unsigned *)fh2p + fh2p->fh2_b_mpoffset); - ODS2MAP *map = kmalloc(sizeof(ODS2MAP), GFP_KERNEL); - ODS2MAP *mapfst = map; - struct buffer_head *bh = NULL; - int idx = 0; - u8 mapinuse = 0; + * This function retreives all file mapping pointers and create a linked list so + * VBN's can be translated to LBN's. + * Note that this routine read ALL mapping pointers thus creating a catedral window + * for the file. Should there be extension headers they are all read directly not + * using iget to fetch them. + */ +struct ods2map * +getmap (struct super_block *sb, struct fh2def *fh2p) { + struct fm2def *fm2p = (struct fm2def *) ((short unsigned *)fh2p + fh2p->fh2_b_mpoffset); + struct ods2map *map; + struct ods2map *mapfst; + struct buffer_head *bh = NULL; + int idx = 0; + u8 mapinuse = 0; - if (map == NULL) { + mapfst = map = kmalloc (sizeof (struct ods2map), GFP_KERNEL); + if (!map) { printk("ODS2-fs kmalloc failed for getmap (1)\n"); return NULL; } - memset(map, 0, sizeof(ODS2MAP)); + memset (map, 0, sizeof (struct ods2map)); + do { mapinuse = fh2p->fh2_b_map_inuse; - while (fm2p < (FM2DEF *)((short unsigned *)fh2p + fh2p->fh2_b_acoffset) && mapinuse > 0) { - u32 cnt = 0; - u32 lbn = 0; - u16 size = 0; - + while (fm2p < (struct fm2def *)((short unsigned *)fh2p + fh2p->fh2_b_acoffset) && mapinuse > 0) { + u32 cnt = 0; + u32 lbn = 0; + u16 size = 0; + switch (fm2p->u1.fm1.fm2_v_format) { - case 0: size = 1; break; - case 1: cnt = fm2p->u1.fm1.fm2_b_count1; lbn = (fm2p->u1.fm1.fm2_v_highlbn << 16) | fm2p->u1.fm1.fm2_w_lowlbn; size = 2; break; - case 2: cnt = fm2p->u1.fm2.fm2_v_count2; lbn = (le16_to_cpu(fm2p->u1.fm2.fm2_l_lbn2[1]) << 16) | le16_to_cpu(fm2p->u1.fm2.fm2_l_lbn2[0]); size = 3; break; - case 3: cnt = (fm2p->u1.fm3.fm2_v_count2 << 16) | le16_to_cpu(fm2p->u1.fm3.fm2_w_lowcount); lbn = le32_to_cpu(fm2p->u1.fm3.fm2_l_lbn3); size = 4; break; + case 0: size = 1; break; + case 1: cnt = fm2p->u1.fm1.fm2_b_count1; lbn = (fm2p->u1.fm1.fm2_v_highlbn << 16) | fm2p->u1.fm1.fm2_w_lowlbn; size = 2; break; + case 2: cnt = fm2p->u1.fm2.fm2_v_count2; lbn = (le16_to_cpu(fm2p->u1.fm2.fm2_l_lbn2[1]) << 16) | le16_to_cpu(fm2p->u1.fm2.fm2_l_lbn2[0]); size = 3; break; + case 3: cnt = (fm2p->u1.fm3.fm2_v_count2 << 16) | le16_to_cpu(fm2p->u1.fm3.fm2_w_lowcount); lbn = le32_to_cpu(fm2p->u1.fm3.fm2_l_lbn3); size = 4; break; } if (fm2p->u1.fm1.fm2_v_format > 0) { if (idx > 15) { - if ((map->nxt = kmalloc(sizeof(ODS2MAP), GFP_KERNEL)) != NULL) { + map->nxt = kmalloc (sizeof (struct ods2map), GFP_KERNEL); + if (map->nxt) { map = map->nxt; - memset(map, 0, sizeof(ODS2MAP)); + memset (map, 0, sizeof (struct ods2map)); idx = 0; } else { printk("ODS2-fs kmalloc failed for getmap (2)\n"); @@ -121,27 +127,26 @@ idx++; } mapinuse -= size; - fm2p = (FM2DEF *)((short unsigned *)(fm2p) + size); + fm2p = (struct fm2def *) ((short unsigned *) (fm2p) + size); } /* - If there is an extension header we need to read all of them because - they could have additional mapping information. - - Note that we can not use iget to fetch the extension header because - it is not a valid inode for an ODS2 file. Only primary file header - can be used as an inode. - */ - + * If there is an extension header we need to read all of them because + * they could have additional mapping information. + * + * Note that we can not use iget to fetch the extension header because + * it is not a valid inode for an ODS2 file. Only primary file header + * can be used as an inode. + */ if (fh2p->u3.s1.fid_w_ex_fidnum != 0) { - u32 lbn; - + u32 lbn; + if ((lbn = ino2fhlbn(sb, le16_to_cpu(fh2p->u3.s1.fid_w_ex_fidnum) | (fh2p->u3.s1.fid_b_ex_fidnmx << 16))) != 0) { fh2p = NULL; brelse(bh); - if ((bh = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL && bh->b_data != NULL) { - fh2p = (FH2DEF *)(GETBLKP(sb, lbn, bh->b_data)); - fm2p = (FM2DEF *)((short unsigned *)fh2p + fh2p->fh2_b_mpoffset); + if ((bh = sb_bread(sb, GETBLKNO (sb, lbn))) != NULL && bh->b_data != NULL) { + fh2p = (struct fh2def *) (GETBLKP(sb, lbn, bh->b_data)); + fm2p = (struct fm2def *) ((short unsigned *) fh2p + fh2p->fh2_b_mpoffset); } } } else { @@ -154,14 +159,13 @@ struct buffer_head *getfilebh(struct file *filp, u32 vbn) { - struct inode *inode = filp->f_dentry->d_inode; - struct super_block *sb = inode->i_sb; - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - + struct inode *inode = filp->f_dentry->d_inode; + struct super_block *sb = inode->i_sb; + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; if ((vbn - 1) * 512 < inode->i_size) { - u32 lbn; + u32 lbn; if ((lbn = vbn2lbn(sb, ods2fhp->map, vbn)) > 0) { @@ -183,10 +187,11 @@ return NULL; } - -int verify_fh(FH2DEF *fh2p, u32 ino) { - u16 *p = (short unsigned *)fh2p; - u16 chksum = 0; +int +verify_fh (struct fh2def *fh2p, u32 ino) +{ + u16 *p = (short unsigned *) fh2p; + u16 chksum = 0; for (; p < (short unsigned *)&(fh2p->fh2_w_checksum) ; chksum += le16_to_cpu(*p++)); if (fh2p->fh2_b_idoffset <= fh2p->fh2_b_mpoffset && @@ -203,12 +208,11 @@ return 0; } - int -save_raw (ARGBLK *argblk) +save_raw (struct argblk *argblk) { struct super_block *sb = (struct super_block *) argblk->arg; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); ods2p->flags.v_raw = 1; return 1; @@ -216,10 +220,10 @@ int -save_lowercase (ARGBLK *argblk) +save_lowercase (struct argblk *argblk) { struct super_block *sb = (struct super_block *) argblk->arg; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); ods2p->flags.v_lowercase = 1; return 1; @@ -230,7 +234,7 @@ save_dollar (ARGBLK *argblk) { struct super_block *sb = (struct super_block *) argblk->arg; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); ods2p->dollar = argblk->token[0]; return 1; @@ -241,7 +245,7 @@ save_semicolon (ARGBLK *argblk) { struct super_block *sb = (struct super_block *) argblk->arg; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); ods2p->semicolon = argblk->token[0]; return 1; @@ -250,7 +254,7 @@ int save_version(ARGBLK *argblk) { struct super_block *sb = (struct super_block *) argblk->arg; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); ods2p->flags.v_version = argblk->mask; return 1; Index: CHANGES =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/CHANGES,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CHANGES 19 Sep 2004 19:51:15 -0000 1.2 +++ CHANGES 20 Sep 2004 05:39:06 -0000 1.3 @@ -1,3 +1,9 @@ +Changes from version 0.9.4a to 0.9.4b +===================================== + - Removal of all typedefs. The source now properly uses + struct xxx instead of XXX + - Still compiles, but not tested even with one filesystem image. + Changes from version 0.9.3 to 0.9.4a ==================================== - Quick'n'dirty port from 2.4.x to 2.6.x Index: inode.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/inode.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- inode.c 19 Sep 2004 19:51:15 -0000 1.3 +++ inode.c 20 Sep 2004 05:39:07 -0000 1.4 @@ -64,11 +64,11 @@ ods2_lookup (struct inode *dir, struct dentry *dentry, struct nameidata *nd) { struct super_block *sb = dir->i_sb; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); struct buffer_head *bh; char *vp; u16 *rec; - ODS2FH *ods2fhp = (ODS2FH *) dir->u.generic_ip; + struct ods2fh *ods2fhp = (struct ods2fh *) dir->u.generic_ip; u32 vbn = 1; u32 lbn; int vers = 0; @@ -101,7 +101,7 @@ rec = (u16 *)(GETBLKP(sb, lbn, bh->b_data)); while (*rec != 65535 && *rec != 0) { - DIRDEF *dire = (DIRDEF *)rec; + struct dirdef *dire = (struct dirdef *) rec; if (dire->u1.s1.dir_b_namecount == strlen(name)) { char dirname[dire->u1.s1.dir_b_namecount + 1]; @@ -119,11 +119,11 @@ int curbyte = 0; while (curbyte < dire->u1.s1.dir_w_size) { - u32 ino; - DIRDEF *dirv = (DIRDEF *)((char *)dire + ((dire->u1.s1.dir_b_namecount + 1) & ~1) + 6 + curbyte); + u32 ino; + struct dirdef *dirv = (struct dirdef *) ((char *)dire + ((dire->u1.s1.dir_b_namecount + 1) & ~1) + 6 + curbyte); if (dirv->u1.s2.dir_w_version == vers || vers == 0) { - struct inode *inode; + struct inode *inode; ino = (dirv->u1.s2.u2.s3.fid_b_nmx << 16) | le16_to_cpu(dirv->u1.s2.u2.s3.fid_w_num); brelse(bh); @@ -187,30 +187,28 @@ ods2_read_inode (struct inode *inode) { struct super_block *sb = inode->i_sb; - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); struct buffer_head *bh; u32 fhlbn; if ((fhlbn = ino2fhlbn(sb, inode->i_ino)) > 0 && (bh = sb_bread(sb, GETBLKNO(sb, fhlbn))) != NULL && bh->b_data != NULL) { + struct fh2def *fh2p = (struct fh2def *) GETBLKP(sb, fhlbn, bh->b_data); - FH2DEF *fh2p = (FH2DEF *)(GETBLKP(sb, fhlbn, bh->b_data)); - - if ((inode->u.generic_ip = kmalloc(sizeof(ODS2FH), GFP_KERNEL)) != NULL) { - - ODS2FH *ods2fhp; - FI2DEF *fi2p; - FATDEF *fatp; + if ((inode->u.generic_ip = kmalloc (sizeof (struct ods2fh), GFP_KERNEL)) != NULL) { + struct ods2fh *ods2fhp; + struct fi2def *fi2p; + struct fatdef *fatp; - ods2fhp = (ODS2FH *)inode->u.generic_ip; + ods2fhp = (struct ods2fh *) inode->u.generic_ip; ods2fhp->map = NULL; ods2fhp->ods2vari = NULL; - fi2p = (FI2DEF *)((short unsigned *)fh2p + fh2p->fh2_b_idoffset); - fatp = (FATDEF *)&(fh2p->fh2_w_recattr); + fi2p = (struct fi2def *) ((short unsigned *)fh2p + fh2p->fh2_b_idoffset); + fatp = (struct fatdef *) &(fh2p->fh2_w_recattr); if (verify_fh(fh2p, inode->i_ino)) { - memcpy(&ods2fhp->fat, fatp, sizeof(FATDEF)); + memcpy(&ods2fhp->fat, fatp, sizeof (struct fatdef)); ods2fhp->map = getmap(sb, fh2p); if (fh2p->u4.s1.fch_v_directory) { @@ -247,8 +245,8 @@ inode->i_size += le16_to_cpu(fatp->fat_w_ffbyte); if ((fatp->u0.s0.fat_v_rtype == FAT_C_VFC || fatp->u0.s0.fat_v_rtype == FAT_C_VARIABLE) && !ods2p->flags.v_raw) { - if ((ods2fhp->ods2vari = (ODS2VARI *)kmalloc(sizeof(ODS2VARI), GFP_KERNEL)) != NULL) { - memset(ods2fhp->ods2vari, 0 , sizeof(ODS2VARI)); + if ((ods2fhp->ods2vari = (struct ods2vari *) kmalloc(sizeof (struct ods2vari), GFP_KERNEL)) != NULL) { + memset(ods2fhp->ods2vari, 0 , sizeof (struct ods2vari)); sema_init(&(ods2fhp->ods2vari->sem), 1); } else { printk("ODS2-fs kmalloc failed for vari data\n"); @@ -280,28 +278,28 @@ void ods2_clear_inode(struct inode *inode) { - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; if (ods2fhp != NULL) { - ODS2MAP *map = ods2fhp->map; - + struct ods2map *map = ods2fhp->map; + while (map != NULL) { - ODS2MAP *nxt = map->nxt; - + struct ods2map *nxt = map->nxt; + kfree(map); map = nxt; } ods2fhp->map = NULL; if (ods2fhp->ods2vari != NULL) { /* in case the file was of variable record type */ - int idx; - + int idx; + for (idx = 0; idx < 128; idx++) { - ODS2VAR *ods2varp = ods2fhp->ods2vari->ods2varp[idx]; - + struct ods2var *ods2varp = ods2fhp->ods2vari->ods2varp[idx]; + while (ods2varp != NULL) { - ODS2VAR *nxt = ods2varp->nxt; - + struct ods2var *nxt = ods2varp->nxt; + kfree(ods2varp); ods2varp = nxt; } Index: super.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/super.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- super.c 19 Sep 2004 19:51:15 -0000 1.4 +++ super.c 20 Sep 2004 05:39:07 -0000 1.5 @@ -31,7 +31,7 @@ */ static void ods2_put_super(struct super_block *sb) { - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); if (ods2p != NULL) { iput(ods2p->indexf); /* release INDEXF.SYS;1 */ @@ -47,7 +47,7 @@ */ int ods2_statfs(struct super_block *sb, struct kstatfs *buf) { - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); memcpy(buf, &ods2p->kstatfs, sizeof(struct kstatfs)); return 0; @@ -78,20 +78,20 @@ */ int ods2_read_bitmap(struct super_block *sb) { - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); struct inode *inode; struct buffer_head *bh; if ((inode = iget(sb, 2)) != NULL) { /* this is BITMAP.SYS */ - ODS2FH *ods2fhp = (ODS2FH *)(inode->u.generic_ip); - u32 lbn; + struct ods2fh *ods2fhp = (struct ods2fh *) (inode->u.generic_ip); + u32 lbn; if ((lbn = vbn2lbn(sb, ods2fhp->map, 1)) > 0 && (bh = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL && bh->b_data != NULL) { - struct scbdef *scb = (SCBDEF *)(GETBLKP(sb, lbn, bh->b_data)); - short unsigned *p; - short unsigned chksum = 0; + struct scbdef *scb = (struct scbdef *) GETBLKP(sb, lbn, bh->b_data); + short unsigned *p; + short unsigned chksum = 0; for (p = (short unsigned *)scb ; p < (short unsigned *)&(scb->scb_w_checksum) ; chksum += *p++); @@ -99,9 +99,9 @@ scb->scb_w_cluster == ods2p->hm2.hm2_w_cluster && scb->scb_w_checksum == chksum) { - struct buffer_head *bh2; - u32 vbn = 1; - u32 bitset = 0; + struct buffer_head *bh2; + u32 vbn = 1; + u32 bitset = 0; /* We need to loop through all bytes that make up the bitmap. @@ -144,7 +144,7 @@ int ods2_read_ibitmap (struct super_block *sb) { - ODS2SB *ods2p = ODS2_SB (sb); + struct ods2sb *ods2p = ODS2_SB (sb); int idx; struct buffer_head *bh; @@ -177,7 +177,7 @@ ods2_fill_super(struct super_block *sb, void *data, int silent) { struct buffer_head *bh; - ODS2SB *ods2p; + struct ods2sb *ods2p; sb_set_blocksize(sb, get_hardsect_size(sb->s_dev)); if ((bh = sb_bread(sb, GETBLKNO(sb, 1))) != NULL && bh->b_data != NULL) { @@ -186,12 +186,12 @@ u16 chksum1 = 0; u16 chksum2 = 0; - if ((ODS2_SB (sb) = kmalloc(sizeof(ODS2SB), GFP_KERNEL)) == NULL) { + if ((ODS2_SB (sb) = kmalloc(sizeof(struct ods2sb), GFP_KERNEL)) == NULL) { printk("ODS2-fs kmalloc failed for sb generic\n"); return -ENOMEM; } ods2p = ODS2_SB (sb); - memcpy(&ods2p->hm2, GETBLKP(sb, 1, bh->b_data), sizeof(HM2DEF)); + memcpy(&ods2p->hm2, GETBLKP(sb, 1, bh->b_data), sizeof (struct hm2def)); brelse(bh); for (p = (u16 *)&(ods2p->hm2) ; p < (u16 *)&(ods2p->hm2.hm2_w_checksum1) ; chksum1 += *p++); Index: file.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/file.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- file.c 19 Sep 2004 19:51:15 -0000 1.3 +++ file.c 20 Sep 2004 05:39:07 -0000 1.4 @@ -64,8 +64,8 @@ long unsigned arg) { struct super_block *sb = inode->i_sb; - ODS2SB *ods2p = ODS2_SB (sb); - ODS2FILE *ods2filep = (ODS2FILE *) filp->private_data; + struct ods2sb *ods2p = ODS2_SB (sb); + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; int error = -ENOTTY; int onoff; @@ -117,16 +117,19 @@ */ -int update_virtual_file_pos(loff_t loff, ODS2VARI *ods2vari, u64 currec) { - ODS2VAR *ods2varp = NULL; - int idxvar = IDXVAR(loff); - int idxvari = IDXVARI(loff); - int idxblock = IDXBLOCK(loff); - - if (ods2vari->ods2varp[idxvari] == NULL) { - if ((ods2vari->ods2varp[idxvari] = (ODS2VAR *)kmalloc(sizeof(ODS2VAR), GFP_KERNEL)) != NULL) { - memset(ods2vari->ods2varp[idxvari], 0, sizeof(ODS2VAR)); - } else { +int +update_virtual_file_pos (loff_t loff, struct ods2vari *ods2vari, u64 currec) +{ + struct ods2var *ods2varp; + int idxvar = IDXVAR (loff); + int idxvari = IDXVARI (loff); + int idxblock = IDXBLOCK (loff); + + if (!ods2vari->ods2varp[idxvari]) { + ods2vari->ods2varp[idxvari] = kmalloc (sizeof (struct ods2var), GFP_KERNEL); + if (ods2vari->ods2varp[idxvari]) + memset(ods2vari->ods2varp[idxvari], 0, sizeof (struct ods2var)); + else { printk("ODS2-fs kmalloc failed for new varp (1)\n"); return 0; } @@ -134,16 +137,17 @@ ods2varp = ods2vari->ods2varp[idxvari]; for (; idxblock > 0; idxblock--) { if (ods2varp->nxt == NULL) { - if ((ods2varp->nxt = (ODS2VAR *)kmalloc(sizeof(ODS2VAR), GFP_KERNEL)) != NULL) { - memset(ods2varp->nxt, 0, sizeof(ODS2VAR)); - } else { + ods2varp->nxt = kmalloc (sizeof (struct ods2var), GFP_KERNEL); + if (ods2varp->nxt) + memset(ods2varp->nxt, 0, sizeof (struct ods2var)); + else { printk("ODS2-fs kmalloc failed for new varp (2)\n"); return 0; } } ods2varp = ods2varp->nxt; } - if (ods2varp != NULL && ods2varp->s1[idxvar].loff == 0) { + if (ods2varp && ods2varp->s1[idxvar].loff == 0) { ods2varp->s1[idxvar].recoffs = currec; ods2varp->s1[idxvar].loff = loff; ods2vari->highidx = loff; @@ -190,15 +194,17 @@ */ -ssize_t ods2_read_variable(struct file *filp, char *buf, size_t buflen, loff_t *loff) { - struct inode *inode = filp->f_dentry->d_inode; - char *buforg = buf; - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - ODS2VARI *ods2vari = ods2fhp->ods2vari; - FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); - u32 vbn = 0; - u16 cpylen; +ssize_t +ods2_read_variable(struct file *filp, char *buf, size_t buflen, loff_t *loff) +{ + struct inode *inode = filp->f_dentry->d_inode; + char *buforg = buf; + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + struct fatdef *fatp = (struct fatdef *) &(ods2fhp->fat); + struct ods2vari *ods2vari = ods2fhp->ods2vari; + u32 vbn = 0; + u16 cpylen; if (*loff == 0) { @@ -321,12 +327,14 @@ None. */ -ssize_t ods2_read_stream(struct file *filp, char *buf, size_t buflen, loff_t *loff) { - struct inode *inode = filp->f_dentry->d_inode; - char *buforg = buf; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - u32 vbn = 0; - u16 cpylen; +ssize_t +ods2_read_stream(struct file *filp, char *buf, size_t buflen, loff_t *loff) +{ + struct inode *inode = filp->f_dentry->d_inode; + char *buforg = buf; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + u32 vbn = 0; + u16 cpylen; while (*loff < inode->i_size) { vbn = *loff >> 9; @@ -383,13 +391,12 @@ */ ssize_t ods2_read(struct file *filp, char *buf, size_t buflen, loff_t *loff) { - struct inode *inode = filp->f_dentry->d_inode; - struct super_block *sb = inode->i_sb; - ODS2SB *ods2p = ODS2_SB (sb); - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); - + struct inode *inode = filp->f_dentry->d_inode; + struct super_block *sb = inode->i_sb; + struct ods2sb *ods2p = ODS2_SB (sb); + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + struct fatdef *fatp = (struct fatdef *) &(ods2fhp->fat); if (ods2p->flags.v_raw || ods2filep->u1.s1.v_raw) { return ods2_read_stream(filp, buf, buflen, loff); @@ -516,19 +523,21 @@ */ -loff_t ods2_llseek_variable(struct file *filp, loff_t loff, int seek) { - struct inode *inode = filp->f_dentry->d_inode; - ODS2VAR *ods2varp = NULL; - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - ODS2VARI *ods2vari = ods2fhp->ods2vari; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); - int idxblock = 0; - loff_t offs = 0; - loff_t coffs = 0; - loff_t currec = 0; - u32 vbn = 0; - u16 reclen = 0; +loff_t +ods2_llseek_variable(struct file *filp, loff_t loff, int seek) +{ + struct inode *inode = filp->f_dentry->d_inode; + struct ods2var *ods2varp = NULL; + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; + struct ods2vari *ods2vari = ods2fhp->ods2vari; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + struct fatdef *fatp = (struct fatdef *) &(ods2fhp->fat); + int idxblock = 0; + loff_t offs = 0; + loff_t coffs = 0; + loff_t currec = 0; + u32 vbn = 0; + u16 reclen = 0; offs = loff; if (seek == 0) { /* SEEK_SET */ @@ -626,12 +635,12 @@ loff_t ods2_llseek(struct file *filp, loff_t loff, int seek) { - struct inode *inode = filp->f_dentry->d_inode; - struct super_block *sb = inode->i_sb; - ODS2SB *ods2p = ODS2_SB (sb); - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); + struct inode *inode = filp->f_dentry->d_inode; + struct super_block *sb = inode->i_sb; + struct ods2sb *ods2p = ODS2_SB (sb); + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + struct fatdef *fatp = (struct fatdef *) &(ods2fhp->fat); if (ods2p->flags.v_raw || ods2filep->u1.s1.v_raw) { return ods2_llseek_stream(filp, loff, seek); @@ -656,16 +665,17 @@ int ods2_open_release(struct inode *inode, struct file *filp) { if (filp->private_data == NULL) { - if ((filp->private_data = kmalloc(sizeof(ODS2FILE), GFP_KERNEL)) != NULL) { - memset(filp->private_data, 0, sizeof(ODS2FILE)); - } else { + filp->private_data = kmalloc (sizeof (struct ods2file), GFP_KERNEL); + if (filp->private_data) + memset (filp->private_data, 0, sizeof (struct ods2file)); + else { printk("ODS2-fs kmalloc failed for open_release\n"); return 0; } } else { - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - - if (ods2filep != NULL) { + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + + if (ods2filep) { brelse(ods2filep->bhp); kfree(filp->private_data); } Index: ods2.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/ods2.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ods2.h 19 Sep 2004 19:51:15 -0000 1.3 +++ ods2.h 20 Sep 2004 05:39:07 -0000 1.4 @@ -28,10 +28,9 @@ /* - This is the home block on a ODS2 disk. -*/ - -typedef struct hm2def { + * This is the home block on a ODS2 disk. + */ +struct hm2def { u32 hm2_l_homelbn; u32 hm2_l_alhomelbn; u32 hm2_l_altidxlbn; @@ -84,14 +83,13 @@ char hm2_t_format[12]; u16 hm2_w_res4; u16 hm2_w_checksum2; -} HM2DEF; +}; /* - This is the Storage Control Block. - It is the first block in file BITMAP.SYS. -*/ - -typedef struct scbdef { + * This is the Storage Control Block. + * It is the first block in file BITMAP.SYS. + */ +struct scbdef { union { u16 scb_w_struclev; struct { @@ -134,14 +132,13 @@ u64 scb_q_genernum; u8 scb_b_reserved[446]; u16 scb_w_checksum; -} SCBDEF; +}; /* - This structure is part of the file header block and - fives different tomes as well as the file name. -*/ - -typedef struct fi2def { + * This structure is part of the file header block and + * fives different tomes as well as the file name. + */ +struct fi2def { char fi2_t_filename[20]; u16 fi2_w_revision; u16 fi2_q_credate[4]; @@ -149,14 +146,13 @@ u16 fi2_q_expdate[4]; u16 fi2_q_bakdate[4]; char fi_2_filenameext[66]; -} FI2DEF; +}; /* - This is the file header for any ODS2 file. - It is located in file INDEXF.SYS. -*/ - -typedef struct fh2def { + * This is the file header for any ODS2 file. + * It is located in file INDEXF.SYS. + */ +struct fh2def { u8 fh2_b_idoffset; u8 fh2_b_mpoffset; u8 fh2_b_acoffset; @@ -237,14 +233,13 @@ u8 fh2_r_class_prot[20]; u8 fh2_b_res4[402]; u16 fh2_w_checksum; -} FH2DEF; +}; /* - This is the file attribute structure. - It is part of the file header. - It defines RMS attributes for any file. -*/ - + * This is the file attribute structure. + * It is part of the file header. + * It defines RMS attributes for any file. + */ #define FAT_C_UNDEFINED 0 #define FAT_C_FIXED 1 #define FAT_C_VARIABLE 2 @@ -264,7 +259,7 @@ #define FAT_M_NOSPAN 0x08 #define FAT_M_MSBRCW 0x10 -typedef struct fatdef { +struct fatdef { union { u8 fat_b_rtype; struct { @@ -296,15 +291,14 @@ u8 fat_b_res1[6]; u16 fat_w_notused; u16 fat_w_versions; -} FATDEF; +}; /* - This is the structure used for mapping virtual block - number, VBN, to logical block numbers, LBN. - One or more of this structure is part of the file header. -*/ - -typedef struct fm2def { + * This is the structure used for mapping virtual block + * number, VBN, to logical block numbers, LBN. + * One or more of this structure is part of the file header. + */ +struct fm2def { union { struct { u8 fm2_b_count1; @@ -324,16 +318,14 @@ u32 fm2_l_lbn3; } fm3; } u1; -} FM2DEF; +}; /* - This structure define a directory entry in a directory file. -*/ - + * This structure define a directory entry in a directory file. + */ #define DIR_C_FID 0 #define DIR_C_LINKNAME 1 - -typedef struct dirdef { +struct dirdef { union { struct { u16 dir_w_size; @@ -363,111 +355,104 @@ } u2; } s2; } u1; -} DIRDEF; - +}; /* - From here we have our own ODS2 specific structures - and definitions. -*/ - -typedef struct ods2map { + * From here we have our own ODS2 specific structures + * and definitions. + */ +struct ods2map { struct ods2map *nxt; struct { u32 cnt; u32 lbn; } s1[16]; -} ODS2MAP; +}; /* - Each block map 64Kbyte * 16 loff's. - The number of bytes for this structure is 4 + 16 * 16 => 260. - For a 1GB file we need a total of 1024 blocks. If each block is - 260 bytes the total amount of bytes is 1024 * 260 => 266240 bytes - The linked list will contain no more than 8 blocks as the structure - below has 128 pointers. -*/ - -typedef struct ods2var { + * Each block map 64Kbyte * 16 loff's. + * The number of bytes for this structure is 4 + 16 * 16 => 260. + * For a 1GB file we need a total of 1024 blocks. If each block is + * 260 bytes the total amount of bytes is 1024 * 260 => 266240 bytes + * The linked list will contain no more than 8 blocks as the structure + * below has 128 pointers. + */ +struct ods2var { struct ods2var *nxt; /* next block if needed */ struct { u64 recoffs; /* offset to start of record */ loff_t loff; /* virtual offset to start of record */ } s1[16]; -} ODS2VAR; +}; /* - Each file that is of variable record type has the following structure - attached to it. - This is the index for one or more ODS2VAR structures. By doing index as - much as possible it is easy to calculate what structure to use by just - doing some shifts and bit masking. - Note that this structure and its sub structures are protected by a - semaphore because more than one process at the same time can use the inode - structure to read the file contents. - The number of bytes for this structure is 128 * 4 + 12 (or 16) => 528. - The overhead for small files are big but 528 bytes allocated using kmalloc - should not be to much. -*/ - -#define IDXVAR(a) ((a >> 16) & 0x0f) -#define IDXVARI(a) ((a >> 20) & 0x7f) -#define IDXBLOCK(a) (a >> 27) - -typedef struct ods2vari { - ODS2VAR *ods2varp[128]; /* pointers to ods2var blocks */ - struct semaphore sem; /* This is the semaphore used to protect this structure */ - loff_t highidx; /* highest index so far... */ -} ODS2VARI; + * Each file that is of variable record type has the following structure + * attached to it. + * This is the index for one or more ODS2VAR structures. By doing index as + * much as possible it is easy to calculate what structure to use by just + * doing some shifts and bit masking. + * Note that this structure and its sub structures are protected by a + * semaphore because more than one process at the same time can use the inode + * structure to read the file contents. + * The number of bytes for this structure is 128 * 4 + 12 (or 16) => 528. + * The overhead for small files are big but 528 bytes allocated using kmalloc + * should not be to much. + */ +#define IDXVAR(a) (((a) >> 16) & 0x0f) +#define IDXVARI(a) (((a) >> 20) & 0x7f) +#define IDXBLOCK(a) ((a) >> 27) +struct ods2vari { + struct ods2var *ods2varp[128]; /* pointers to ods2var blocks */ + struct semaphore sem; /* This is the semaphore used + to protect this structure */ + loff_t highidx; /* highest index so far... */ +}; /* - Each open file has the following structure attached to it. - It add the extra variables needed to handle directories and - RMS data. -*/ - -typedef struct ods2file { - struct buffer_head *bhp; - u8 *data; /* pointer to data portion in buffer */ - u64 currec; /* byte offset to current record --- from start of file */ - u16 curbyte; /* byte offset into current record */ - u16 reclen; /* length of current record */ + * Each open file has the following structure attached to it. + * It add the extra variables needed to handle directories and + * RMS data. + */ +struct ods2file { + struct buffer_head *bhp; + u8 *data; /* pointer to data portion in buffer */ + u64 currec; /* byte offset to current record --- from start of file */ + u16 curbyte; /* byte offset into current record */ + u16 reclen; /* length of current record */ union { - u32 flags; + u32 flags; struct { - u32 v_raw:1; /* this file handler must return data in raw mode */ - u32 v_res1:31; + u32 v_raw:1; /* this file handler must + return data in raw mode */ + u32 v_res1:31; } s1; } u1; -} ODS2FILE; +}; /* - Each inode has the following structure attached to it. - It keep the file attributes and mapping information in memory. -*/ - -typedef struct ods2fh { - ODS2MAP *map; /* mapping information from VBN to LBN */ - ODS2VARI *ods2vari; /* only used for variable record files */ - FATDEF fat; /* file attributes */ - u32 parent; /* ino of parent directory */ -} ODS2FH; + * Each inode has the following structure attached to it. + * It keep the file attributes and mapping information in memory. + */ +struct ods2fh { + struct ods2map *map; /* mapping information from VBN to LBN */ + struct ods2vari *ods2vari; /* only used for variable record files */ + struct fatdef fat; /* file attributes */ + u32 parent; /* ino of parent directory */ +}; /* - The super block for an ODS2 disk has the following - structure attached. - It keep the home block and the inode for INDEXF.SYS;1 - in memory. -*/ - -#define SB_M_VERSALL 0 -#define SB_M_VERSHIGH 1 -#define SB_M_VERSNONE 2 -#define SB_M_RAW 8 -#define SB_M_LOWERCASE 16 - -typedef struct ods2sb { - HM2DEF hm2; + * The super block for an ODS2 disk has the following + * structure attached. + * It keep the home block and the inode for INDEXF.SYS;1 + * in memory. + */ +#define SB_M_VERSALL 0 +#define SB_M_VERSHIGH 1 +#define SB_M_VERSNONE 2 +#define SB_M_RAW 8 +#define SB_M_LOWERCASE 16 +struct ods2sb { + struct hm2def hm2; struct inode *indexf; /* INDEXF.SYS */ u8 *ibitmap; /* index file header bitmap */ struct kstatfs kstatfs; @@ -479,65 +464,60 @@ } flags; char dollar; /* character used for dollar */ char semicolon; /* character used for semicolon */ -} ODS2SB; +}; /* - These two macros are used to support media with a sector size of - 1024 or 2048 bytes. - I.e. the RRD47 CDROM drive on my Alpha server 1200 report a sector - size of 2048 even for an ODS2 CD. -*/ + * These two macros are used to support media with a sector size of + * 1024 or 2048 bytes. + * I.e. the RRD47 CDROM drive on my Alpha server 1200 report a sector + * size of 2048 even for an ODS2 CD. + */ -#define GETBLKNO(a, b) ((b) >> (a->s_blocksize_bits - 9)) -#define GETBLKP(a, b, c) (void *)&(((char *)c)[((b) & (a->s_blocksize_bits == 9 ? 0 : (a->s_blocksize_bits == 10 ? 1 : 3))) << 9]) +#define GETBLKNO(a, b) ((b) >> (a->s_blocksize_bits - 9)) +#define GETBLKP(a, b, c) ((void *)&(((char *)(c))[((b) & ((a)->s_blocksize_bits == 9 ? 0 : ((a)->s_blocksize_bits == 10 ? 1 : 3))) << 9])) /* - This is our private ioctl operations for a file pointer. -*/ - -#define ODS2_IOC_FISETRAW _IOW('f', 0x0d0, long) /* enable/disable raw file mode */ -#define ODS2_IOC_FIGETRAW _IOR('g', 0x0d0, long) /* get raw file mode */ -#define ODS2_IOC_SBGETRAW _IOR('g', 0x0d1, long) /* get raw mode for super block */ + * This is our private ioctl operations for a file pointer. + */ +#define ODS2_IOC_FISETRAW _IOW('f', 0x0d0, long) /* enable/disable raw file mode */ +#define ODS2_IOC_FIGETRAW _IOR('g', 0x0d0, long) /* get raw file mode */ +#define ODS2_IOC_SBGETRAW _IOR('g', 0x0d1, long) /* get raw mode for super block */ -#define MIN(a, b) (a < b ? a : b) -#define MAX(a, b) (a > b ? a : b) +#define MIN(a, b) ((a) < (b)? (a): (b)) /* FIXME - deprecated! */ +#define MAX(a, b) ((a) > (b)? (a): (b)) /* FIXME - deprecated! */ /* - util.c -*/ - -u64 div64(u64 a, u32 b0); -u32 vbn2lbn(struct super_block *sb, ODS2MAP *map, u32 vbn); -u32 ino2fhlbn(struct super_block *sb, u32 ino); -ODS2MAP *getmap(struct super_block *sb, FH2DEF *fh2p); -struct buffer_head *getfilebh(struct file *filp, u32 vbn); -int verify_fh(FH2DEF *fh2p, u32 ino); -int parse_options(struct super_block *sb, char *options); + * util.c + */ +extern u64 div64(u64 a, u32 b0); +extern u32 vbn2lbn(struct super_block *sb, struct ods2map *map, u32 vbn); +extern u32 ino2fhlbn(struct super_block *sb, u32 ino); +extern struct ods2map *getmap(struct super_block *sb, struct fh2def *fh2p); +extern struct buffer_head *getfilebh(struct file *filp, u32 vbn); +extern int verify_fh(struct fh2def *fh2p, u32 ino); +extern int parse_options(struct super_block *sb, char *options); /* - inode.c -*/ - -struct dentry *ods2_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd); -void ods2_read_inode(struct inode *inode); -void ods2_put_inode(struct inode *inode); -void ods2_clear_inode(struct inode *inode); -void ods2_delete_inode(struct inode *inode); + * inode.c + */ +extern struct dentry *ods2_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd); +extern void ods2_read_inode(struct inode *inode); +extern void ods2_put_inode(struct inode *inode); +extern void ods2_clear_inode(struct inode *inode); +extern void ods2_delete_inode(struct inode *inode); /* - dir.c -*/ - -int ods2_readdir(struct file *filp, void *dirent, filldir_t filldir); + * dir.c + */ +extern int ods2_readdir(struct file *filp, void *dirent, filldir_t filldir); /* - file.c -*/ - -int ods2_file_ioctl(struct inode *inode, struct file *filp, int unsigned cmd, long unsigned arg); -ssize_t ods2_read(struct file *filp, char *buf, size_t buflen, loff_t *loff); -loff_t ods2_llseek(struct file *filp, loff_t loff, int seek); -int ods2_open_release(struct inode *inode, struct file *filp); + * file.c + */ +extern int ods2_file_ioctl(struct inode *inode, struct file *filp, int unsigned cmd, long unsigned arg); +extern ssize_t ods2_read(struct file *filp, char *buf, size_t buflen, loff_t *loff); +extern loff_t ods2_llseek(struct file *filp, loff_t loff, int seek); +extern int ods2_open_release(struct inode *inode, struct file *filp); /* * util.c @@ -545,7 +525,7 @@ extern time_t vms2unix_sec (u16 *vms_timestamp); extern long vms2unix_nsec (u16 *vms_timestamp); -/* Hacks in util.c */ +/* FIXME: hacks in util.c */ extern int get_hardsect_size (int xx); #endif /* _ODS2_H */ Index: dir.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/dir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dir.c 19 Sep 2004 19:51:15 -0000 1.3 +++ dir.c 20 Sep 2004 05:39:07 -0000 1.4 @@ -34,24 +34,24 @@ int ods2_readdir (struct file *filp, void *dirent, filldir_t filldir) { - struct inode *inode = filp->f_dentry->d_inode; - struct super_block *sb = inode->i_sb; - struct buffer_head *bh = NULL; - ODS2SB *ods2p = ODS2_SB (sb); - ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - loff_t pos = filp->f_pos; - u32 vbn = (ods2filep->currec >> 9); /* get current VBN-1 to use */ - u32 lbn; - char cdirname[256]; + struct inode *inode = filp->f_dentry->d_inode; + struct super_block *sb = inode->i_sb; + struct buffer_head *bh = NULL; + struct ods2sb *ods2p = ODS2_SB (sb); + struct ods2fh *ods2fhp = (struct ods2fh *) inode->u.generic_ip; + struct ods2file *ods2filep = (struct ods2file *) filp->private_data; + loff_t pos = filp->f_pos; + u32 vbn = (ods2filep->currec >> 9); /* get current VBN-1 to use */ + u32 lbn; + char cdirname[256]; /* FIXME: large stack useage!!! */ - memset(cdirname, ' ', sizeof(cdirname)); + memset (cdirname, ' ', sizeof (cdirname)); /* - When there are no more files to return the file position in file - is set to -1. - */ - - if (pos == -1) return 0; + * When there are no more files to return the file position in file + * is set to -1. + */ + if (pos == -1) + return 0; /* When we get called the first time for a directory file the file @@ -87,14 +87,14 @@ */ while (*recp != 65535 && *recp <= 512 && ods2filep->currec < inode->i_size) { - DIRDEF *dire = (DIRDEF *)recp; - char dirname[dire->u1.s1.dir_b_namecount + 1]; - + struct dirdef *dire = (struct dirdef *) recp; + char dirname[dire->u1.s1.dir_b_namecount + 1]; /* FIXME: Check stack useage */ + memcpy(dirname, &dire->u1.s1.dir_t_name, dire->u1.s1.dir_b_namecount); dirname[dire->u1.s1.dir_b_namecount] = 0; if (ods2p->dollar != '$' || ods2p->flags.v_lowercase) { - char *p = dirname; - char cnt = dire->u1.s1.dir_b_namecount; + char *p = dirname; + char cnt = dire->u1.s1.dir_b_namecount; while (*p && cnt-- > 0) { if (*p == '$') { *p = ods2p->dollar; } if (ods2p->flags.v_lowercase) { *p = tolower(*p); } p++; } } @@ -104,25 +104,23 @@ while (ods2filep->curbyte < dire->u1.s1.dir_w_size && !(ods2p->flags.v_version != SB_M_VERSALL && strlen(dirname) == strlen(cdirname) && strncmp(dirname, cdirname, strlen(dirname)) == 0)) { - DIRDEF *dirv = (DIRDEF *)((char *)dire + ods2filep->curbyte); - u32 ino = (dirv->u1.s2.u2.s3.fid_b_nmx << 16) | le16_to_cpu(dirv->u1.s2.u2.s3.fid_w_num); - char dirnamev[dire->u1.s1.dir_b_namecount + 1 + 5 + 1]; - + struct dirdef *dirv = (struct dirdef *) ((char *)dire + ods2filep->curbyte); + u32 ino = (dirv->u1.s2.u2.s3.fid_b_nmx << 16) | le16_to_cpu(dirv->u1.s2.u2.s3.fid_w_num); + char dirnamev[dire->u1.s1.dir_b_namecount + 1 + 5 + 1]; /* FIXME: Check stack useage! */ + if (ino != 4) { /* we must ignore 000000.DIR as it is the same as . */ - if (ods2p->flags.v_version == SB_M_VERSNONE) { + if (ods2p->flags.v_version == SB_M_VERSNONE) sprintf(dirnamev, "%s", dirname); - } else { + else sprintf(dirnamev, "%s%c%d", dirname, ods2p->semicolon, dirv->u1.s2.dir_w_version); - } /* - We don't really know if the file is a directory by just checking - the file extension but it is the best we can do. - Should the file have extension .DIR but be a regular file the mistake - will be detected later on when the user try to walk down into - the false directory. - */ - + * We don't really know if the file is a directory by just checking + * the file extension but it is the best we can do. + * Should the file have extension .DIR but be a regular file the mistake + * will be detected later on when the user try to walk down into + * the false directory. + */ if (filldir(dirent, dirnamev, strlen(dirnamev), filp->f_pos, ino, (strstr(dirnamev, (ods2p->flags.v_lowercase ? ".dir." : ".DIR")) == NULL ? DT_REG : DT_DIR))) { /* |