|
From: Jan-Benedict G. <jb...@us...> - 2004-09-22 07:10:48
|
Update of /cvsroot/linux-vax/kernel-2.5/fs/ods2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13852 Modified Files: dir.c super.c Log Message: - More eye-candy. Index: super.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/super.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- super.c 22 Sep 2004 06:24:30 -0000 1.10 +++ super.c 22 Sep 2004 07:10:35 -0000 1.11 @@ -25,11 +25,10 @@ #include "ods2.h" /* - This routine is executed when the ODS2 file system is unmounted. - The only thing we need to do is to release file INDEXF.SYS;1 and - deallocate memory used for index file header bitmap. -*/ - + * This routine is executed when the ODS2 file system is unmounted. + * The only thing we need to do is to release file INDEXF.SYS;1 and + * deallocate memory used for index file header bitmap. + */ static void ods2_put_super(struct super_block *sb) { struct ods2sb *ods2p = ODS2_SB (sb); @@ -41,11 +40,10 @@ } /* - This routine is executed when the user want to get information - about the ODS2 file system. As we are read only we can just copy - the information we were gathering during the mount into the buffer. -*/ - + * This routine is executed when the user want to get information + * about the ODS2 file system. As we are read only we can just copy + * the information we were gathering during the mount into the buffer. + */ int ods2_statfs(struct super_block *sb, struct kstatfs *buf) { struct ods2sb *ods2p = ODS2_SB (sb); @@ -68,15 +66,13 @@ /* - This array is used to get the number of bits set for a nibble value. -*/ - + * This array is used to get the number of bits set for a nibble value. + * */ static char unsigned nibble2bits[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; /* - This routine open and read the BITMAP.SYS;1 file. -*/ - + * This routine open and read the BITMAP.SYS;1 file. + */ int ods2_read_bitmap(struct super_block *sb) { struct ods2sb *ods2p = ODS2_SB (sb); struct inode *inode; @@ -86,37 +82,37 @@ 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) { - + if ((lbn = vbn2lbn(sb, ods2fhp->map, 1)) > 0 + && (bh = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL + && bh->b_data != NULL) { 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++); - if (scb->u1.s1.scb_b_structlevl == 2 && scb->u1.s1.scb_b_structlevv >= 1 && - scb->scb_w_cluster == ods2p->hm2.hm2_w_cluster && - scb->scb_w_checksum == chksum) { - + if (scb->u1.s1.scb_b_structlevl == 2 + && scb->u1.s1.scb_b_structlevv >= 1 + && scb->scb_w_cluster == ods2p->hm2.hm2_w_cluster + && scb->scb_w_checksum == chksum) { struct buffer_head *bh2; u32 vbn = 1; u32 bitset = 0; /* - We need to loop through all bytes that make up the bitmap. - The fastest way to count the number of bits set in the byte - is to have a nibble table that has the number of bits for the - values of 0 to 15. By adding the number of bits for the low - and high nibble we can get the total amount of bits set. - */ + * We need to loop through all bytes that make up the bitmap. + * The fastest way to count the number of bits set in the byte + * is to have a nibble table that has the number of bits for the + * values of 0 to 15. By adding the number of bits for the low + * and high nibble we can get the total amount of bits set. + */ + while (vbn * 512 < inode->i_size + && (lbn = vbn2lbn(sb, ods2fhp->map, vbn + 1)) > 0 + && (bh2 = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL + && bh->b_data != NULL) { + u8 *bp = (char unsigned *)(GETBLKP(sb, lbn, bh2->b_data)); + int cnt; - while (vbn * 512 < inode->i_size && (lbn = vbn2lbn(sb, ods2fhp->map, vbn + 1)) > 0 && - (bh2 = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL && bh->b_data != NULL) { - - u8 *bp = (char unsigned *)(GETBLKP(sb, lbn, bh2->b_data)); - int cnt; - for (cnt = 0; cnt < 512; cnt++, bp++) { bitset += (nibble2bits[*bp & 0x0f] + nibble2bits[*bp >> 4]); } brelse(bh2); vbn++; @@ -137,10 +133,10 @@ } /* - This routine allocate memory for the index file header bitmap - and copy data from the INDEXF.SYS file. At the same time the - number of free file headers are counted. -*/ + * This routine allocate memory for the index file header bitmap + * and copy data from the INDEXF.SYS file. At the same time the + * number of free file headers are counted. + */ int ods2_read_ibitmap (struct super_block *sb) { @@ -153,8 +149,8 @@ memset(ods2p->ibitmap, 0, (ods2p->hm2.hm2_w_ibmapsize << 9)); for (idx = 0 ; idx < ods2p->hm2.hm2_w_ibmapsize ; idx++) { if ((bh = sb_bread(sb, GETBLKNO(sb, ods2p->hm2.hm2_l_ibmaplbn + idx))) != NULL && bh->b_data != NULL) { - u8 *bp = (GETBLKP(sb, ods2p->hm2.hm2_l_ibmaplbn + idx, bh->b_data)); - int cnt; + u8 *bp = (GETBLKP(sb, ods2p->hm2.hm2_l_ibmaplbn + idx, bh->b_data)); + int cnt; memcpy((ods2p->ibitmap + (idx << 9)), GETBLKP(sb, ods2p->hm2.hm2_l_ibmaplbn + idx, bh->b_data), 512); for (cnt = 0; cnt < 512; cnt++, bp++) { @@ -338,20 +334,18 @@ /* * This is the way to check for a valid home block. */ - if (ods2p->hm2.hm2_l_homelbn != 0 && - ods2p->hm2.hm2_l_alhomelbn != 0 && - ods2p->hm2.hm2_l_altidxlbn != 0 && - ods2p->hm2.hm2_w_cluster != 0 && - ods2p->hm2.u1.s1.hm2_b_structlevl == 2 && - ods2p->hm2.u1.s1.hm2_b_structlevv >= 1 && - ods2p->hm2.hm2_w_homevbn != 0 && - ods2p->hm2.hm2_l_ibmaplbn != 0 && - ods2p->hm2.hm2_l_maxfiles > ods2p->hm2.hm2_w_resfiles && - ods2p->hm2.hm2_w_resfiles >= 5 && - chksum1 == ods2p->hm2.hm2_w_checksum1 && - chksum2 == ods2p->hm2.hm2_w_checksum2) { - - + if (ods2p->hm2.hm2_l_homelbn != 0 + && ods2p->hm2.hm2_l_alhomelbn != 0 + && ods2p->hm2.hm2_l_altidxlbn != 0 + && ods2p->hm2.hm2_w_cluster != 0 + && ods2p->hm2.u1.s1.hm2_b_structlevl == 2 + && ods2p->hm2.u1.s1.hm2_b_structlevv >= 1 + && ods2p->hm2.hm2_w_homevbn != 0 + && ods2p->hm2.hm2_l_ibmaplbn != 0 + && ods2p->hm2.hm2_l_maxfiles > ods2p->hm2.hm2_w_resfiles + && ods2p->hm2.hm2_w_resfiles >= 5 + && chksum1 == ods2p->hm2.hm2_w_checksum1 + && chksum2 == ods2p->hm2.hm2_w_checksum2) { sb->s_op = &ods2_sops; ods2p->indexf = iget(sb, 1); /* read INDEXF.SYS. */ Index: dir.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/dir.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- dir.c 20 Sep 2004 21:15:47 -0000 1.7 +++ dir.c 22 Sep 2004 07:10:35 -0000 1.8 @@ -43,6 +43,7 @@ char cdirname[256]; /* FIXME: large stack useage!!! */ memset (cdirname, ' ', sizeof (cdirname)); + /* * When there are no more files to return the file position in file * is set to -1. @@ -51,11 +52,10 @@ return 0; /* - When we get called the first time for a directory file the file - position is set to 0. We must then return two fake entries, - . for the current directory and .. for the parent directory. - */ - + * When we get called the first time for a directory file, the file + * position is set to 0. We must then return two fake entries, + * "." for the current directory and ".." for the parent directory. + */ if (pos == 0) { filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR); filldir(dirent, "..", 2, 1, ods2fhp->parent, DT_DIR); @@ -65,45 +65,61 @@ } /* - As long we can translate the virtual block number, VBN, to a - logical block number, LBN, and read the block we continue to loop. - */ - - while (vbn * 512 < inode->i_size && (lbn = vbn2lbn(sb, ods2fhp->map, vbn + 1)) > 0 && - (bh = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL && bh->b_data != NULL) { - - u16 *recp = (short unsigned *)((char *)(GETBLKP(sb, lbn, bh->b_data)) + (ods2filep->currec & 511)); + * As long we can translate the virtual block number, VBN, to a + * logical block number, LBN, and read the block we continue to loop. + */ + while (vbn * 512 < inode->i_size + && (lbn = vbn2lbn(sb, ods2fhp->map, vbn + 1)) > 0 + && (bh = sb_bread(sb, GETBLKNO(sb, lbn))) != NULL && + bh->b_data != NULL) { + u16 *recp = (short unsigned *)((char *)(GETBLKP(sb, lbn, bh->b_data)) + (ods2filep->currec & 511)); /* - For a ODS2 directory each block contains 1 to 62 directory entries. - Note that a directory entry can not span between two or more blocks. - We should be able to use the routine to read variable block size but - because directory file is so specific we do our own block decoding here. - When there are no more directory entries in the current block the record - length -1 is inserted as the last record. - */ - - while (*recp != 65535 && *recp <= 512 && ods2filep->currec < inode->i_size) { + * For a ODS2 directory each block contains 1 to 62 directory + * entries. Note that a directory entry can not span between + * two or more blocks. We should be able to use the routine + * to read variable block size but because directory file is + * so specific we do our own block decoding here. + * When there are no more directory entries in the current + * block, the record length -1 is inserted as the last + * record. + */ + while (*recp != 65535 + && *recp <= 512 + && ods2filep->currec < inode->i_size) { 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; - while (*p && cnt-- > 0) { if (*p == '$') { *p = ods2p->dollar; } if (ods2p->flags.v_lowercase) { *p = tolower(*p); } p++; } + while (*p && cnt-- > 0) { + if (*p == '$') { + *p = ods2p->dollar; + } + if (ods2p->flags.v_lowercase) { + *p = tolower (*p); + } + p++; + } + } + if (ods2filep->curbyte == 0) { + ods2filep->curbyte = ((dire->u1.s1.dir_b_namecount + 1) & ~1) + 6; } - if (ods2filep->curbyte == 0) { ods2filep->curbyte = ((dire->u1.s1.dir_b_namecount + 1) & ~1) + 6; } filp->f_pos = ods2filep->currec + ods2filep->curbyte; - 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)) { - + 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)) { 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! */ + /* FIXME: Check stack useage! */ + char dirnamev[dire->u1.s1.dir_b_namecount + 1 + 5 + 1]; if (ino != 4) { /* we must ignore 000000.DIR as it is the same as . */ if (ods2p->flags.v_version == SB_M_VERSNONE) @@ -127,7 +143,9 @@ brelse(bh); return 0; } - if (ods2p->flags.v_version != SB_M_VERSALL) { strcpy(cdirname, dirname); } + if (ods2p->flags.v_version != SB_M_VERSALL) { + strcpy(cdirname, dirname); + } } if (ods2p->flags.v_version == SB_M_VERSALL) { ods2filep->curbyte += 8; |