summaryrefslogtreecommitdiffstats
path: root/fs/hpfs
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-23 00:40:54 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-23 00:40:54 +0000
commit529c593ece216e4aaffd36bd940cb94f1fa63129 (patch)
tree78f1c0b805f5656aa7b0417a043c5346f700a2cf /fs/hpfs
parent0bd079751d25808d1972baee5c4eaa1db2227257 (diff)
Merge with 2.3.43. I did ignore all modifications to the qlogicisp.c
driver due to the Origin A64 hacks.
Diffstat (limited to 'fs/hpfs')
-rw-r--r--fs/hpfs/dir.c4
-rw-r--r--fs/hpfs/file.c62
-rw-r--r--fs/hpfs/hpfs_fn.h4
-rw-r--r--fs/hpfs/inode.c61
-rw-r--r--fs/hpfs/namei.c11
5 files changed, 61 insertions, 81 deletions
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 36e665c32..280c47244 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -8,7 +8,7 @@
#include "hpfs_fn.h"
-int hpfs_dir_read(struct file *filp, char *name, size_t len, loff_t *loff)
+ssize_t hpfs_dir_read(struct file *filp, char *name, size_t len, loff_t *loff)
{
return -EISDIR;
}
@@ -242,6 +242,8 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry)
if (!de->directory) {
if (result->i_size == -1) {
result->i_size = de->file_size;
+ result->i_data.a_ops = &hpfs_aops;
+ result->u.hpfs_i.mmu_private = result->i_size;
/*
* i_blocks should count the fnode and any anodes.
* We count 1 for the fnode and don't bother about
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index 8abaf2fd3..710b9120b 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -54,6 +54,7 @@ void hpfs_truncate(struct inode *i)
if (IS_IMMUTABLE(i)) return /*-EPERM*/;
i->i_hpfs_n_secs = 0;
i->i_blocks = 1 + ((i->i_size + 511) >> 9);
+ i->u.hpfs_i.mmu_private = i->i_size;
hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
hpfs_write_inode(i);
}
@@ -61,63 +62,60 @@ void hpfs_truncate(struct inode *i)
int hpfs_get_block(struct inode *inode, long iblock, struct buffer_head *bh_result, int create)
{
secno s;
- if (iblock < inode->i_blocks - 1) {
- s = hpfs_bmap(inode, iblock);
+ s = hpfs_bmap(inode, iblock);
+ if (s) {
bh_result->b_dev = inode->i_dev;
bh_result->b_blocknr = s;
bh_result->b_state |= (1UL << BH_Mapped);
return 0;
}
if (!create) return 0;
- if (iblock > inode->i_blocks - 1) {
- //hpfs_error(inode->i_sb, "hpfs_get_block beyond file end (requested %08x, inode size %08x", (int)iblock, (int)inode->i_blocks - 1);
- printk("HPFS: could not write beyond file end. This is known bug.\n");
- return -EFSERROR;
+ if (iblock<<9 != inode->u.hpfs_i.mmu_private) {
+ BUG();
+ return -EIO;
}
if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) {
hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1);
return -ENOSPC;
}
inode->i_blocks++;
+ inode->u.hpfs_i.mmu_private += 512;
bh_result->b_dev = inode->i_dev;
bh_result->b_blocknr = s;
bh_result->b_state |= (1UL << BH_Mapped) | (1UL << BH_New);
return 0;
}
-static int hpfs_write_partial_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf)
+static int hpfs_writepage(struct dentry *dentry, struct page *page)
{
- struct dentry *dentry = file->f_dentry;
- struct inode *inode = dentry->d_inode;
- struct page *new_page;
- unsigned long pgpos;
- long status;
-
- pgpos = ((inode->i_blocks - 1) * 512) >> PAGE_CACHE_SHIFT;
- while (pgpos < page->index) {
- status = -ENOMEM;
- new_page = grab_cache_page(&inode->i_data, pgpos);
- if (!new_page)
- goto out;
- status = block_write_cont_page(file, new_page, PAGE_SIZE, 0, NULL);
- UnlockPage(new_page);
- page_cache_release(new_page);
- if (status < 0)
- goto out;
- pgpos = ((inode->i_blocks - 1) * 512) >> PAGE_CACHE_SHIFT;
- }
- status = block_write_cont_page(file, page, offset, bytes, buf);
-out:
- return status;
+ return block_write_full_page(page,hpfs_get_block);
}
-
+static int hpfs_readpage(struct dentry *dentry, struct page *page)
+{
+ return block_read_full_page(page,hpfs_get_block);
+}
+static int hpfs_prepare_write(struct page *page, unsigned from, unsigned to)
+{
+ return cont_prepare_write(page,from,to,hpfs_get_block,
+ &((struct inode*)page->mapping->host)->u.hpfs_i.mmu_private);
+}
+static int _hpfs_bmap(struct address_space *mapping, long block)
+{
+ return generic_block_bmap(mapping,block,hpfs_get_block);
+}
+struct address_space_operations hpfs_aops = {
+ readpage: hpfs_readpage,
+ writepage: hpfs_writepage,
+ prepare_write: hpfs_prepare_write,
+ commit_write: generic_commit_write,
+ bmap: _hpfs_bmap
+};
ssize_t hpfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
ssize_t retval;
- retval = generic_file_write(file, buf, count,
- ppos, hpfs_write_partial_page);
+ retval = generic_file_write(file, buf, count, ppos);
if (retval > 0) {
struct inode *inode = file->f_dentry->d_inode;
inode->i_mtime = CURRENT_TIME;
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index d1e70e579..f0324cffa 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -224,7 +224,7 @@ void hpfs_set_dentry_operations(struct dentry *);
/* dir.c */
-int hpfs_dir_read(struct file *, char *, size_t, loff_t *);
+ssize_t hpfs_dir_read(struct file *, char *, size_t, loff_t *);
int hpfs_dir_release(struct inode *, struct file *);
loff_t hpfs_dir_lseek(struct file *, loff_t, int);
int hpfs_readdir(struct file *, void *, filldir_t);
@@ -314,3 +314,5 @@ void hpfs_put_super(struct super_block *);
unsigned hpfs_count_one_bitmap(struct super_block *, secno);
int hpfs_statfs(struct super_block *, struct statfs *, int);
struct super_block *hpfs_read_super(struct super_block *, void *, int);
+
+extern struct address_space_operations hpfs_aops;
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 0b6ab8053..2fa2d0dd4 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -10,19 +10,12 @@
static const struct file_operations hpfs_file_ops =
{
- NULL, /* lseek - default */
- generic_file_read, /* read */
- hpfs_file_write, /* write */
- NULL, /* readdir - bad */
- NULL, /* poll - default */
- NULL, /* ioctl - default */
- generic_file_mmap, /* mmap */
- hpfs_open, /* open */
- NULL, /* flush */
- hpfs_file_release, /* release */
- hpfs_file_fsync, /* fsync */
- NULL, /* fasync */
- NULL, /* lock */
+ read: generic_file_read,
+ write: hpfs_file_write,
+ mmap: generic_file_mmap,
+ open: hpfs_open,
+ release: hpfs_file_release,
+ fsync: hpfs_file_fsync,
};
static const struct inode_operations hpfs_file_iops =
@@ -39,29 +32,17 @@ static const struct inode_operations hpfs_file_iops =
NULL, /* rename */
NULL, /* readlink */
NULL, /* follow_link */
- &hpfs_get_block, /* get_block */
- block_read_full_page, /* readpage */
- block_write_full_page, /* writepage */
hpfs_truncate, /* truncate */
- NULL, /* permission */
- NULL, /* revalidate */
};
static const struct file_operations hpfs_dir_ops =
{
- hpfs_dir_lseek, /* lseek */
- hpfs_dir_read, /* read */
- NULL, /* write - bad */
- hpfs_readdir, /* readdir */
- NULL, /* poll - default */
- NULL, /* ioctl - default */
- NULL, /* mmap */
- hpfs_open, /* open */
- NULL, /* flush */
- hpfs_dir_release, /* no special release code */
- hpfs_file_fsync, /* fsync */
- NULL, /* fasync */
- NULL, /* lock */
+ llseek: hpfs_dir_lseek,
+ read: hpfs_dir_read,
+ readdir: hpfs_readdir,
+ open: hpfs_open,
+ release: hpfs_dir_release,
+ fsync: hpfs_file_fsync,
};
static const struct inode_operations hpfs_dir_iops =
@@ -76,20 +57,9 @@ static const struct inode_operations hpfs_dir_iops =
hpfs_rmdir, /* rmdir */
hpfs_mknod, /* mknod */
hpfs_rename, /* rename */
- NULL, /* readlink */
- NULL, /* follow_link */
- NULL, /* get_block */
- NULL, /* readpage */
- NULL, /* writepage */
- NULL, /* truncate */
- NULL, /* permission */
- NULL /* revalidate */
};
-const struct inode_operations hpfs_symlink_iops =
-{
- readlink: page_readlink,
- follow_link: page_follow_link,
+struct address_space_operations hpfs_symlink_aops = {
readpage: hpfs_symlink_readpage
};
@@ -164,7 +134,8 @@ void hpfs_read_inode(struct inode *i)
if ((ea = hpfs_get_ea(i->i_sb, fnode, "SYMLINK", &ea_size))) {
kfree(ea);
i->i_mode = S_IFLNK | 0777;
- i->i_op = (struct inode_operations *) &hpfs_symlink_iops;
+ i->i_op = &page_symlink_inode_operations;
+ i->i_data.a_ops = &hpfs_symlink_aops;
i->i_nlink = 1;
i->i_size = ea_size;
i->i_blocks = 1;
@@ -219,6 +190,8 @@ void hpfs_read_inode(struct inode *i)
i->i_nlink = 1;
i->i_size = fnode->file_size;
i->i_blocks = ((i->i_size + 511) >> 9) + 1;
+ i->i_data.a_ops = &hpfs_aops;
+ i->u.hpfs_i.mmu_private = i->i_size;
}
brelse(bh);
}
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 85ce143db..3ca25fedf 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -138,7 +138,11 @@ int hpfs_create(struct inode *dir, struct dentry *dentry, int mode)
result->i_hpfs_ea_size = 0;
if (dee.read_only) result->i_mode &= ~0222;
if (result->i_blocks == -1) result->i_blocks = 1;
- if (result->i_size == -1) result->i_size = 0;
+ if (result->i_size == -1) {
+ result->i_size = 0;
+ result->i_data.a_ops = &hpfs_aops;
+ result->u.hpfs_i.mmu_private = 0;
+ }
if (result->i_uid != current->fsuid ||
result->i_gid != current->fsgid ||
result->i_mode != (mode | S_IFREG)) {
@@ -221,7 +225,7 @@ int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
return -ENOSPC;
}
-extern const struct inode_operations hpfs_symlink_iops;
+extern struct address_space_operations hpfs_symlink_aops;
int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink)
{
@@ -268,7 +272,8 @@ int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink)
result->i_gid = current->fsgid;
result->i_blocks = 1;
result->i_size = strlen(symlink);
- result->i_op = (struct inode_operations *) &hpfs_symlink_iops;
+ result->i_op = &page_symlink_inode_operations;
+ result->i_data.a_ops = &hpfs_symlink_aops;
if ((fnode = hpfs_map_fnode(dir->i_sb, fno, &bh))) {
hpfs_set_ea(result, fnode, "SYMLINK", (char *)symlink, strlen(symlink));
mark_buffer_dirty(bh, 1);