Re: how to write get_block?

Alexander Viro (viro@math.psu.edu)
Fri, 8 Oct 1999 04:58:35 -0400 (EDT)


On Sat, 2 Oct 1999, Mikulas Patocka wrote:

> Hi.
>
> I'm porting my HPFS driver to 2.3.18 and I don't know how to write
> get_block properly. When user does lseek(far beyond file end) and
> write(), get_block must allocate a lot of sectors and clear them (HPFS
> doesn't support holes). The question is: what call should I use to
> clear these sectors?

Use the (fixed) variant of FAT code. I.e block_write_cont_page() +
equivalent of fat_write_partial_page().

> What should I do with it? Is there any function that I didn't notice? Of
> course I could write routines to directly touch page cache and attach
> buffer there, but I think it's dirty. Especially when other filesystem
> also need to do the same (fat currently crashes when writing beyond file
> end, other filesystems aren't ported yet)

FAT should be OK now.

diff -urN linux-2.3.19/fs/buffer.c linux-bird.fat/fs/buffer.c
--- linux-2.3.19/fs/buffer.c Sun Sep 12 13:29:57 1999
+++ linux-bird.fat/fs/buffer.c Fri Oct 8 03:59:06 1999
@@ -1512,8 +1512,8 @@
char * target_buf, *target_data;
unsigned long data_offset = offset;

- offset = page->offset-inode->i_size;
- if (offset < 0)
+ offset = inode->i_size - page->offset;
+ if (page->offset>inode->i_size)
offset = 0;
else if (offset >= data_offset)
offset = data_offset;
diff -urN linux-2.3.19/fs/fat/file.c linux-bird.fat/fs/fat/file.c
--- linux-2.3.19/fs/fat/file.c Sun Sep 12 11:56:11 1999
+++ linux-bird.fat/fs/fat/file.c Fri Oct 8 03:59:46 1999
@@ -118,7 +118,7 @@
unsigned long page_cache = 0;
long status;

- pgpos = inode->i_size & PAGE_CACHE_MASK;
+ pgpos = MSDOS_I(inode)->i_realsize & PAGE_CACHE_MASK;
while (pgpos < page->offset) {
hash = page_hash(inode, pgpos);
repeat_find: new_page = __find_lock_page(inode, pgpos, hash);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/