|
From: Adrian M. <zx8...@us...> - 2002-11-05 00:03:07
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs/vmufs
In directory usw-pr-cvs1:/tmp/cvs-serv6413/fs/vmufs
Modified Files:
Tag: linux-sh-dc-2_4-branch
inode.c super.c
Log Message:
More vmufs clean-ups/improvements - more still needed
Index: inode.c
===================================================================
RCS file: /cvsroot/linuxdc/linux-sh-dc/fs/vmufs/Attic/inode.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -d -r1.1.2.9 -r1.1.2.10
--- inode.c 3 Nov 2002 19:30:18 -0000 1.1.2.9
+++ inode.c 5 Nov 2002 00:03:04 -0000 1.1.2.10
@@ -25,7 +25,7 @@
struct buffer_head *bh = bread(sb->s_dev, 253, 512);
struct vmufs_file_info *first_one = NULL;
struct vmufs_file_info *last_one = NULL;
- int i, fno = 0;
+ int fno = 0;
do {
struct vmufs_file_info *saved_file =
@@ -48,8 +48,8 @@
((__u8 *) bh->b_data)[1 + fno * 0x20];
saved_file->fblk = ((__u16 *) bh->b_data)[1 + fno * 0x10];
memcpy(saved_file->fname, bh->b_data + 4 + fno * 0x20, 12);
-
-
+
+
fno++;
} while (1);
@@ -96,7 +96,7 @@
}
struct inode_operations vmufs_inode_operations = {
- lookup: vmufs_inode_lookup,
+ lookup:vmufs_inode_lookup,
};
@@ -108,7 +108,7 @@
struct buffer_head *bh = bread(sb->s_dev, 253, 512);
int i = filp->f_pos;
- switch ((unsigned int)filp->f_pos) {
+ switch ((unsigned int) filp->f_pos) {
case 0:
if (filldir(dirent, ".", 1, i++, inode->i_ino, DT_DIR) < 0)
goto finish;
@@ -134,24 +134,28 @@
kmalloc(sizeof(struct vmufs_file_info), GFP_KERNEL);
do {
- saved_file->ftype = ((__u8 *) bh->b_data)[0 + (i - 2) * 0x20];
+ saved_file->ftype =
+ ((__u8 *) bh->b_data)[0 + (i - 2) * 0x20];
if (saved_file->ftype == 0)
break;
saved_file->fblk =
- le16_to_cpu(((__u16 *) bh->b_data)[1 + (i - 2) * 0x10]);
- memcpy(saved_file->fname, bh->b_data + 4 + (i - 2) * 0x20, 12);
+ le16_to_cpu(((__u16 *) bh->b_data)[1 +
+ (i - 2) * 0x10]);
+ memcpy(saved_file->fname, bh->b_data + 4 + (i - 2) * 0x20,
+ 12);
- if (filldir(dirent, saved_file->fname, 12, i++, saved_file->fblk,
- DT_REG) < 0) {
+ if (filldir
+ (dirent, saved_file->fname, 12, i++, saved_file->fblk,
+ DT_REG) < 0) {
goto finish;
}
filp->f_pos++;
} while (1);
-finish:
+ finish:
kfree(saved_file);
brelse(bh);
@@ -160,10 +164,10 @@
}
struct file_operations vmufs_file_dir_operations = {
- owner: THIS_MODULE,
- read: generic_read_dir,
- readdir: vmufs_readdir,
- fsync: file_fsync,
+ owner:THIS_MODULE,
+ read:generic_read_dir,
+ readdir:vmufs_readdir,
+ fsync:file_fsync,
};
ssize_t vmufs_file_read(struct file *file, char *buf, size_t count,
@@ -173,7 +177,9 @@
unsigned long blkoffset = *ppos >> in->i_sb->s_blocksize_bits;
unsigned long blksize = in->i_blksize;
unsigned long blcks_to_read, x;
- struct buffer_head *bh;
+ __u16 fatblk, next_block;
+ struct buffer_head *bh_file;
+ struct buffer_head *bh_fat;
long file_len = in->i_size;
char *readbuf;
@@ -183,13 +189,30 @@
count = file_len - *ppos;
blcks_to_read = count >> in->i_sb->s_blocksize_bits;
+ if (blcks_to_read == 0) return 0;
readbuf = kmalloc(count, GFP_KERNEL);
- for (x = 0; x < blcks_to_read; x++) {
- bh = bread(in->i_sb->s_dev, in->i_ino - blkoffset - x, blksize);
- memcpy(readbuf + x * blksize, bh->b_data, blksize);
- brelse(bh);
+ /* Trverse through FAT to read the blocks in */
+ x = 0;
+ next_block = in->i_ino;
+ bh_fat = bread(in->i_sb->s_dev, 254, blksize);
+ /*Walk through to where we are */
+ if (blkoffset > 0) {
+ do {
+ next_block = ((__u16 *) bh_fat->b_data)[next_block];
+ blkoffset--;
+ } while (blkoffset > 0);
}
+ do {
+ bh_file = bread(in->i_sb->s_dev, next_block, blksize);
+ memcpy(readbuf + x * blksize, bh_file->b_data, blksize);
+ x++;
+ fatblk = ((__u16 *) bh_fat->b_data)[next_block];
+ if (fatblk == 0xfffa)
+ break;
+ next_block = fatblk;
+ } while (x < blcks_to_read);
+
/* Copy to user space */
copy_to_user(buf, readbuf, count);
@@ -200,9 +223,8 @@
}
struct file_operations vmufs_file_operations = {
- read: vmufs_file_read,
+ read:vmufs_file_read,
};
struct inode_operations vmufs_file_inode_operations = {
};
-
Index: super.c
===================================================================
RCS file: /cvsroot/linuxdc/linux-sh-dc/fs/vmufs/Attic/super.c,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -d -r1.1.2.8 -r1.1.2.9
--- super.c 3 Nov 2002 19:51:44 -0000 1.1.2.8
+++ super.c 5 Nov 2002 00:03:04 -0000 1.1.2.9
@@ -31,7 +31,7 @@
#include <linux/time.h>
#include "vmufs.h"
-int int_from_bcd(__u8 bcd)
+inline int int_from_bcd(__u8 bcd)
{
int topnib = (bcd >> 4) & 0x000f;
int botnib = bcd & 0x000f;
|