diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
commit | beb116954b9b7f3bb56412b2494b562f02b864b1 (patch) | |
tree | 120e997879884e1b9d93b265221b939d2ef1ade1 /fs/xiafs | |
parent | 908d4681a1dc3792ecafbe64265783a86c4cccb6 (diff) |
Import of Linux/MIPS 2.1.14
Diffstat (limited to 'fs/xiafs')
-rw-r--r-- | fs/xiafs/Makefile | 28 | ||||
-rw-r--r-- | fs/xiafs/bitmap.c | 21 | ||||
-rw-r--r-- | fs/xiafs/dir.c | 15 | ||||
-rw-r--r-- | fs/xiafs/file.c | 50 | ||||
-rw-r--r-- | fs/xiafs/fsync.c | 14 | ||||
-rw-r--r-- | fs/xiafs/inode.c | 60 | ||||
-rw-r--r-- | fs/xiafs/namei.c | 20 | ||||
-rw-r--r-- | fs/xiafs/symlink.c | 14 | ||||
-rw-r--r-- | fs/xiafs/truncate.c | 4 |
9 files changed, 97 insertions, 129 deletions
diff --git a/fs/xiafs/Makefile b/fs/xiafs/Makefile index b8a19d0bf..e596cc559 100644 --- a/fs/xiafs/Makefile +++ b/fs/xiafs/Makefile @@ -7,28 +7,8 @@ # # Note 2! The CFLAGS definitions are now in the main makefile... -.c.s: - $(CC) $(CFLAGS) -S $< -.c.o: - $(CC) $(CFLAGS) -c $< -.s.o: - $(AS) -o $*.o $< +O_TARGET := xiafs.o +O_OBJS := bitmap.o truncate.o namei.o inode.o file.o dir.o symlink.o fsync.o +M_OBJS := $(O_TARGET) -OBJS= bitmap.o truncate.o namei.o inode.o \ - file.o dir.o symlink.o fsync.o - -xiafs.o: $(OBJS) - $(LD) -r -o xiafs.o $(OBJS) - -modules: xiafs.o - ln -sf ../fs/xiafs/xiafs.o $(TOPDIR)/modules - -dep: - $(CPP) -M *.c > .depend - -# -# include a dependency file if one exists -# -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +include $(TOPDIR)/Rules.make diff --git a/fs/xiafs/bitmap.c b/fs/xiafs/bitmap.c index bca7e4367..15028ce85 100644 --- a/fs/xiafs/bitmap.c +++ b/fs/xiafs/bitmap.c @@ -11,10 +11,6 @@ /* bitmap.c contains the code that handles the inode and block bitmaps */ -#ifdef MODULE -#include <linux/module.h> -#endif - #include <linux/sched.h> #include <linux/locks.h> #include <linux/xia_fs.h> @@ -231,7 +227,7 @@ void xiafs_free_zone(struct super_block * sb, int d_addr) } bh = get_hash_table(sb->s_dev, d_addr, XIAFS_ZSIZE(sb)); if (bh) - bh->b_dirt=0; + mark_buffer_clean(bh); brelse(bh); bit=d_addr - sb->u.xiafs_sb.s_firstdatazone + 1; bh = get_zmap_zone(sb, bit, NULL); @@ -239,9 +235,9 @@ void xiafs_free_zone(struct super_block * sb, int d_addr) return; offset = bit & (XIAFS_BITS_PER_Z(sb) -1); if (!clear_bit(offset, bh->b_data)) - printk("XIA-FS: dev %04x" + printk("XIA-FS: dev %s" " block bit %u (0x%x) already cleared (%s %d)\n", - sb->s_dev, bit, bit, WHERE_ERR); + kdevname(sb->s_dev), bit, bit, WHERE_ERR); mark_buffer_dirty(bh, 1); xiafs_unlock_super(sb, sb->u.xiafs_sb.s_zmap_cached); } @@ -273,7 +269,7 @@ int xiafs_new_zone(struct super_block * sb, u_long prev_addr) return 0; } clear_buf(bh); - bh->b_uptodate = 1; + mark_buffer_uptodate(bh, 1); mark_buffer_dirty(bh, 1); brelse(bh); return tmp; @@ -287,8 +283,9 @@ void xiafs_free_inode(struct inode * inode) if (!inode) return; - if (!inode->i_dev || inode->i_count!=1 || inode->i_nlink || !inode->i_sb || - inode->i_ino < 3 || inode->i_ino > inode->i_sb->u.xiafs_sb.s_ninodes) { + if (!inode->i_dev || inode->i_count!=1 + || inode->i_nlink || !inode->i_sb || inode->i_ino < 3 + || inode->i_ino > inode->i_sb->u.xiafs_sb.s_ninodes) { printk("XIA-FS: bad inode (%s %d)\n", WHERE_ERR); return; } @@ -299,9 +296,9 @@ void xiafs_free_inode(struct inode * inode) return; clear_inode(inode); if (!clear_bit(ino & (XIAFS_BITS_PER_Z(sb)-1), bh->b_data)) - printk("XIA-FS: dev %04x" + printk("XIA-FS: dev %s" "inode bit %ld (0x%lx) already cleared (%s %d)\n", - inode->i_dev, ino, ino, WHERE_ERR); + kdevname(inode->i_dev), ino, ino, WHERE_ERR); mark_buffer_dirty(bh, 1); xiafs_unlock_super(sb, sb->u.xiafs_sb.s_imap_cached); } diff --git a/fs/xiafs/dir.c b/fs/xiafs/dir.c index 5a88c2f0b..856d3cdcd 100644 --- a/fs/xiafs/dir.c +++ b/fs/xiafs/dir.c @@ -9,11 +9,6 @@ * This software may be redistributed per Linux Copyright. */ -#ifdef MODULE -#include <linux/module.h> -#endif - -#include <asm/segment.h> #include <linux/sched.h> #include <linux/errno.h> #include <linux/kernel.h> @@ -21,9 +16,11 @@ #include <linux/xia_fs.h> #include <linux/stat.h> +#include <asm/uaccess.h> + #include "xiafs_mac.h" -static int xiafs_dir_read(struct inode *, struct file *, char *, int); +static long xiafs_dir_read(struct inode *, struct file *, char *, unsigned long); static int xiafs_readdir(struct inode *, struct file *, void *, filldir_t); static struct file_operations xiafs_dir_operations = { @@ -55,13 +52,15 @@ struct inode_operations xiafs_dir_inode_operations = { xiafs_rename, /* rename */ NULL, /* readlink */ NULL, /* follow_link */ + NULL, /* readpage */ + NULL, /* writepage */ NULL, /* bmap */ xiafs_truncate, /* truncate */ NULL /* permission */ }; -static int xiafs_dir_read(struct inode * inode, - struct file * filp, char * buf, int count) +static long xiafs_dir_read(struct inode * inode, struct file * filp, + char * buf, unsigned long count) { return -EISDIR; } diff --git a/fs/xiafs/file.c b/fs/xiafs/file.c index c67daaed9..822b4b520 100644 --- a/fs/xiafs/file.c +++ b/fs/xiafs/file.c @@ -9,13 +9,6 @@ * This software may be redistributed per Linux Copyright. */ -#ifdef MODULE -#include <linux/module.h> -#endif - -#include <asm/segment.h> -#include <asm/system.h> - #include <linux/sched.h> #include <linux/fs.h> #include <linux/xia_fs.h> @@ -24,6 +17,10 @@ #include <linux/fcntl.h> #include <linux/stat.h> #include <linux/locks.h> +#include <linux/pagemap.h> + +#include <asm/uaccess.h> +#include <asm/system.h> #include "xiafs_mac.h" @@ -32,8 +29,8 @@ #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) -static int xiafs_file_read(struct inode *, struct file *, char *, int); -static int xiafs_file_write(struct inode *, struct file *, char *, int); +static long xiafs_file_read(struct inode *, struct file *, char *, unsigned long); +static long xiafs_file_write(struct inode *, struct file *, const char *, unsigned long); /* * We have mostly NULL's here: the current defaults are ok for @@ -46,7 +43,7 @@ static struct file_operations xiafs_file_operations = { NULL, /* readdir - bad */ NULL, /* select - default */ NULL, /* ioctl - default */ - generic_mmap, /* mmap */ + generic_file_mmap, /* mmap */ NULL, /* no special open is needed */ NULL, /* release */ xiafs_sync_file /* fsync */ @@ -65,13 +62,15 @@ struct inode_operations xiafs_file_inode_operations = { NULL, /* rename */ NULL, /* readlink */ NULL, /* follow_link */ + generic_readpage, /* readpage */ + NULL, /* writepage */ xiafs_bmap, /* bmap */ xiafs_truncate, /* truncate */ NULL /* permission */ }; -static int -xiafs_file_read(struct inode * inode, struct file * filp, char * buf, int count) +static long +xiafs_file_read(struct inode * inode, struct file * filp, char * buf, unsigned long count) { int read, left, chars; int zone_nr, zones, f_zones, offset; @@ -107,9 +106,9 @@ xiafs_file_read(struct inode * inode, struct file * filp, char * buf, int count) zones = f_zones - zone_nr; } - /* We do this in a two stage process. We first try and request + /* We do this in a two stage process. We first try to request as many blocks as we can, then we wait for the first one to - complete, and then we try and wrap up as many as are actually + complete, and then we try to wrap up as many as are actually done. This routine is rather generic, in that it can be used in a filesystem by substituting the appropriate function in for getblk. @@ -122,7 +121,7 @@ xiafs_file_read(struct inode * inode, struct file * filp, char * buf, int count) uptodate = 1; while (zones--) { *bhb = xiafs_getblk(inode, zone_nr++, 0); - if (*bhb && !(*bhb)->b_uptodate) { + if (*bhb && !buffer_uptodate(*bhb)) { uptodate = 0; bhreq[bhrequest++] = *bhb; } @@ -145,7 +144,7 @@ xiafs_file_read(struct inode * inode, struct file * filp, char * buf, int count) do { /* Finish off all I/O that has actually completed */ if (*bhe) { wait_on_buffer(*bhe); - if (!(*bhe)->b_uptodate) { /* read error? */ + if (!buffer_uptodate(*bhe)) { /* read error? */ brelse(*bhe); if (++bhe == &buflist[NBUF]) bhe = buflist; @@ -161,17 +160,17 @@ xiafs_file_read(struct inode * inode, struct file * filp, char * buf, int count) left -= chars; read += chars; if (*bhe) { - memcpy_tofs(buf,offset+(*bhe)->b_data,chars); + copy_to_user(buf,offset+(*bhe)->b_data,chars); brelse(*bhe); buf += chars; } else { while (chars-->0) - put_fs_byte(0,buf++); + put_user(0,buf++); } offset = 0; if (++bhe == &buflist[NBUF]) bhe = buflist; - } while (left > 0 && bhe != bhb && (!*bhe || !(*bhe)->b_lock)); + } while (left > 0 && bhe != bhb && (!*bhe || !buffer_locked(*bhe))); } while (left > 0); /* Release the read-ahead blocks */ @@ -190,8 +189,8 @@ xiafs_file_read(struct inode * inode, struct file * filp, char * buf, int count) return read; } -static int -xiafs_file_write(struct inode * inode, struct file * filp, char * buf, int count) +static long +xiafs_file_write(struct inode * inode, struct file * filp, const char * buf, unsigned long count) { off_t pos; int written, c; @@ -225,10 +224,10 @@ xiafs_file_write(struct inode * inode, struct file * filp, char * buf, int count c = XIAFS_ZSIZE(inode->i_sb) - (pos & (XIAFS_ZSIZE(inode->i_sb) - 1)); if (c > count-written) c = count-written; - if (c != XIAFS_ZSIZE(inode->i_sb) && !bh->b_uptodate) { + if (c != XIAFS_ZSIZE(inode->i_sb) && !buffer_uptodate(bh)) { ll_rw_block(READ, 1, &bh); wait_on_buffer(bh); - if (!bh->b_uptodate) { + if (!buffer_uptodate(bh)) { brelse(bh); if (!written) written = -EIO; @@ -236,15 +235,16 @@ xiafs_file_write(struct inode * inode, struct file * filp, char * buf, int count } } cp = (pos & (XIAFS_ZSIZE(inode->i_sb)-1)) + bh->b_data; + copy_from_user(cp,buf,c); + update_vm_cache(inode,pos,cp,c); pos += c; if (pos > inode->i_size) { inode->i_size = pos; inode->i_dirt = 1; } written += c; - memcpy_fromfs(cp,buf,c); buf += c; - bh->b_uptodate = 1; + mark_buffer_uptodate(bh, 1); mark_buffer_dirty(bh, 0); brelse(bh); } diff --git a/fs/xiafs/fsync.c b/fs/xiafs/fsync.c index 5bd0a7066..f491e3d8e 100644 --- a/fs/xiafs/fsync.c +++ b/fs/xiafs/fsync.c @@ -8,13 +8,6 @@ * xiafs fsync primitive */ -#ifdef MODULE -#include <linux/module.h> -#endif - -#include <asm/segment.h> -#include <asm/system.h> - #include <linux/errno.h> #include <linux/sched.h> #include <linux/stat.h> @@ -24,6 +17,9 @@ #include <linux/fs.h> #include <linux/xia_fs.h> +#include <asm/uaccess.h> +#include <asm/system.h> + #include "xiafs_mac.h" @@ -45,11 +41,11 @@ static int sync_block (struct inode * inode, unsigned long * block, int wait) brelse (bh); return 1; } - if (wait && bh->b_req && !bh->b_uptodate) { + if (wait && buffer_req(bh) && !buffer_uptodate(bh)) { brelse(bh); return -1; } - if (wait || !bh->b_uptodate || !bh->b_dirt) + if (wait || !buffer_uptodate(bh) || !buffer_dirty(bh)) { brelse(bh); return 0; diff --git a/fs/xiafs/inode.c b/fs/xiafs/inode.c index 5f9fc833a..48b31e972 100644 --- a/fs/xiafs/inode.c +++ b/fs/xiafs/inode.c @@ -9,13 +9,7 @@ * This software may be redistributed per Linux Copyright. */ -#ifdef MODULE #include <linux/module.h> -#include <linux/version.h> -#else -#define MOD_INC_USE_COUNT -#define MOD_DEC_USE_COUNT -#endif #include <linux/sched.h> #include <linux/xia_fs.h> @@ -25,7 +19,7 @@ #include <linux/stat.h> #include <linux/locks.h> #include <asm/system.h> -#include <asm/segment.h> +#include <asm/uaccess.h> #include "xiafs_mac.h" @@ -70,16 +64,17 @@ struct super_block *xiafs_read_super(struct super_block *s, void *data, { struct buffer_head *bh; struct xiafs_super_block *sp; - int i, z, dev; + int i, z; + kdev_t dev; MOD_INC_USE_COUNT; - dev=s->s_dev; + dev = s->s_dev; lock_super(s); set_blocksize(dev, BLOCK_SIZE); if (!(bh = bread(dev, 0, BLOCK_SIZE))) { - s->s_dev=0; + s->s_dev = 0; unlock_super(s); printk("XIA-FS: read super_block failed (%s %d)\n", WHERE_ERR); MOD_DEC_USE_COUNT; @@ -92,8 +87,8 @@ struct super_block *xiafs_read_super(struct super_block *s, void *data, unlock_super(s); brelse(bh); if (!silent) - printk("VFS: Can't find a xiafs filesystem on dev 0x%04x.\n", - dev); + printk("VFS: Can't find a xiafs filesystem on dev " + "%s.\n", kdevname(dev)); MOD_DEC_USE_COUNT; return NULL; } @@ -164,7 +159,7 @@ xiafs_read_super_fail: brelse(s->u.xiafs_sb.s_imap_buf[i]); for(i=0; i < _XIAFS_ZMAP_SLOTS; i++) brelse(s->u.xiafs_sb.s_zmap_buf[i]); - s->s_dev=0; + s->s_dev = 0; unlock_super(s); printk("XIA-FS: read bitmaps failed (%s %d)\n", WHERE_ERR); MOD_DEC_USE_COUNT; @@ -183,7 +178,7 @@ void xiafs_statfs(struct super_block *sb, struct statfs *buf, int bufsiz) tmp.f_files = sb->u.xiafs_sb.s_ninodes; tmp.f_ffree = xiafs_count_free_inodes(sb); tmp.f_namelen = _XIAFS_NAME_LEN; - memcpy_tofs(buf, &tmp, bufsiz); + copy_to_user(buf, &tmp, bufsiz); } static int zone_bmap(struct buffer_head * bh, int nr) @@ -285,10 +280,10 @@ indt_getblk(struct inode * inode, struct buffer_head * bh, if (!bh) return NULL; - if (!bh->b_uptodate) { + if (!buffer_uptodate(bh)) { ll_rw_block(READ, 1, &bh); wait_on_buffer(bh); - if (!bh->b_uptodate) { + if (!buffer_uptodate(bh)) { brelse(bh); return NULL; } @@ -364,11 +359,11 @@ struct buffer_head * xiafs_bread(struct inode * inode, int zone, int create) struct buffer_head * bh; bh = xiafs_getblk(inode, zone, create); - if (!bh || bh->b_uptodate) + if (!bh || buffer_uptodate(bh)) return bh; ll_rw_block(READ, 1, &bh); wait_on_buffer(bh); - if (bh->b_uptodate) + if (buffer_uptodate(bh)) return bh; brelse(bh); return NULL; @@ -408,7 +403,7 @@ void xiafs_read_inode(struct inode * inode) inode->i_blksize = XIAFS_ZSIZE(inode->i_sb); if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { inode->i_blocks=0; - inode->i_rdev = raw_inode->i_zone[0]; + inode->i_rdev = to_kdev_t(raw_inode->i_zone[0]); } else { XIAFS_GET_BLOCKS(raw_inode, inode->i_blocks); for (zone = 0; zone < 8; zone++) @@ -469,7 +464,7 @@ static struct buffer_head * xiafs_update_inode(struct inode * inode) raw_inode->i_ctime = inode->i_ctime; raw_inode->i_mtime = inode->i_mtime; if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) - raw_inode->i_zone[0] = inode->i_rdev; + raw_inode->i_zone[0] = kdev_t_to_nr(inode->i_rdev); else { XIAFS_PUT_BLOCKS(raw_inode, inode->i_blocks); for (zone = 0; zone < 8; zone++) @@ -499,14 +494,14 @@ int xiafs_sync_inode (struct inode *inode) struct buffer_head *bh; bh = xiafs_update_inode(inode); - if (bh && bh->b_dirt) + if (bh && buffer_dirty(bh)) { ll_rw_block(WRITE, 1, &bh); wait_on_buffer(bh); - if (bh->b_req && !bh->b_uptodate) + if (buffer_req(bh) && !buffer_uptodate(bh)) { - printk ("IO error syncing xiafs inode [%04X:%lu]\n", - inode->i_dev, inode->i_ino); + printk ("IO error syncing xiafs inode [%s:%lu]\n", + kdevname(inode->i_dev), inode->i_ino); err = -1; } } @@ -516,20 +511,25 @@ int xiafs_sync_inode (struct inode *inode) return err; } -#ifdef MODULE - /* Every kernel module contains stuff like this. */ -char kernel_version[] = UTS_RELEASE; - static struct file_system_type xiafs_fs_type = { xiafs_read_super, "xiafs", 1, NULL }; +int init_xiafs_fs(void) +{ + return register_filesystem(&xiafs_fs_type); +} + +#ifdef MODULE int init_module(void) { - register_filesystem(&xiafs_fs_type); - return 0; + int status; + + if ((status = init_xiafs_fs()) == 0) + register_symtab(0); + return status; } void cleanup_module(void) diff --git a/fs/xiafs/namei.c b/fs/xiafs/namei.c index 46b3590b2..b23c4bf71 100644 --- a/fs/xiafs/namei.c +++ b/fs/xiafs/namei.c @@ -9,10 +9,6 @@ * This software may be redistributed per Linux Copyright. */ -#ifdef MODULE -#include <linux/module.h> -#endif - #include <linux/sched.h> #include <linux/xia_fs.h> #include <linux/kernel.h> @@ -20,7 +16,8 @@ #include <linux/stat.h> #include <linux/fcntl.h> #include <linux/errno.h> -#include <asm/segment.h> + +#include <asm/uaccess.h> #include "xiafs_mac.h" @@ -317,7 +314,7 @@ int xiafs_mknod(struct inode *dir, const char *name, int len, int mode, int rdev else if (S_ISFIFO(inode->i_mode)) init_fifo(inode); if (S_ISBLK(mode) || S_ISCHR(mode)) - inode->i_rdev = rdev; + inode->i_rdev = to_kdev_t(rdev); inode->i_atime = inode->i_ctime = inode->i_atime = CURRENT_TIME; inode->i_dirt = 1; bh = xiafs_add_entry(dir, name, len, &de, NULL); @@ -716,7 +713,8 @@ static int subdir(struct inode * new_inode, struct inode * old_inode) */ static int do_xiafs_rename(struct inode * old_dir, const char * old_name, int old_len, struct inode * new_dir, - const char * new_name, int new_len) + const char * new_name, int new_len, + int must_be_dir) { struct inode * old_inode, * new_inode; struct buffer_head * old_bh, * new_bh, * dir_bh; @@ -733,6 +731,8 @@ try_again: old_inode = __iget(old_dir->i_sb, old_de->d_ino, 0); /* don't cross mnt-points */ if (!old_inode) goto end_rename; + if (must_be_dir && !S_ISDIR(old_inode->i_mode)) + goto end_rename; retval = -EPERM; if ((old_dir->i_mode & S_ISVTX) && current->fsuid != old_inode->i_uid && @@ -835,7 +835,8 @@ end_rename: * as they are on different partitions. */ int xiafs_rename(struct inode * old_dir, const char * old_name, int old_len, - struct inode * new_dir, const char * new_name, int new_len) + struct inode * new_dir, const char * new_name, int new_len, + int must_be_dir) { static struct wait_queue * wait = NULL; static int lock = 0; @@ -845,7 +846,8 @@ int xiafs_rename(struct inode * old_dir, const char * old_name, int old_len, sleep_on(&wait); lock = 1; result = do_xiafs_rename(old_dir, old_name, old_len, - new_dir, new_name, new_len); + new_dir, new_name, new_len, + must_be_dir); lock = 0; wake_up(&wait); return result; diff --git a/fs/xiafs/symlink.c b/fs/xiafs/symlink.c index 1c64ebc6d..1803ae457 100644 --- a/fs/xiafs/symlink.c +++ b/fs/xiafs/symlink.c @@ -9,18 +9,14 @@ * This software may be redistributed per Linux Copyright. */ -#ifdef MODULE -#include <linux/module.h> -#endif - -#include <asm/segment.h> - #include <linux/errno.h> #include <linux/sched.h> #include <linux/fs.h> #include <linux/xia_fs.h> #include <linux/stat.h> +#include <asm/uaccess.h> + static int xiafs_readlink(struct inode *, char *, int); @@ -43,6 +39,8 @@ struct inode_operations xiafs_symlink_inode_operations = { NULL, /* rename */ xiafs_readlink, /* readlink */ xiafs_follow_link, /* follow_link */ + NULL, /* readpage */ + NULL, /* writepage */ NULL, /* bmap */ NULL, /* truncate */ NULL /* permission */ @@ -69,9 +67,9 @@ static int xiafs_readlink(struct inode * inode, char * buffer, int buflen) if (!bh) return 0; for (i=0; i < buflen && (c=bh->b_data[i]); i++) - put_fs_byte(c, buffer++); + put_user(c, buffer++); if (i < buflen-1) - put_fs_byte((char)0, buffer); + put_user('\0', buffer); brelse(bh); return i; } diff --git a/fs/xiafs/truncate.c b/fs/xiafs/truncate.c index 2e8dec10d..bdb9d39be 100644 --- a/fs/xiafs/truncate.c +++ b/fs/xiafs/truncate.c @@ -9,10 +9,6 @@ * This software may be redistributed per Linux Copyright. */ -#ifdef MODULE -#include <linux/module.h> -#endif - #include <linux/errno.h> #include <linux/sched.h> #include <linux/xia_fs.h> |