libfs.c (5c34202b8bf942da411b6599668a76b07449bbfd) | libfs.c (afddba49d18f346e5cc2938b6ed7c512db18ca68) |
---|---|
1/* 2 * fs/libfs.c 3 * Library for filesystems writers. 4 */ 5 6#include <linux/module.h> 7#include <linux/pagemap.h> 8#include <linux/mount.h> --- 337 unchanged lines hidden (view full) --- 346 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to); 347 flush_dcache_page(page); 348 kunmap_atomic(kaddr, KM_USER0); 349 } 350 } 351 return 0; 352} 353 | 1/* 2 * fs/libfs.c 3 * Library for filesystems writers. 4 */ 5 6#include <linux/module.h> 7#include <linux/pagemap.h> 8#include <linux/mount.h> --- 337 unchanged lines hidden (view full) --- 346 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to); 347 flush_dcache_page(page); 348 kunmap_atomic(kaddr, KM_USER0); 349 } 350 } 351 return 0; 352} 353 |
354int simple_write_begin(struct file *file, struct address_space *mapping, 355 loff_t pos, unsigned len, unsigned flags, 356 struct page **pagep, void **fsdata) 357{ 358 struct page *page; 359 pgoff_t index; 360 unsigned from; 361 362 index = pos >> PAGE_CACHE_SHIFT; 363 from = pos & (PAGE_CACHE_SIZE - 1); 364 365 page = __grab_cache_page(mapping, index); 366 if (!page) 367 return -ENOMEM; 368 369 *pagep = page; 370 371 return simple_prepare_write(file, page, from, from+len); 372} 373 |
|
354int simple_commit_write(struct file *file, struct page *page, 355 unsigned from, unsigned to) 356{ 357 struct inode *inode = page->mapping->host; 358 loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; 359 360 if (!PageUptodate(page)) 361 SetPageUptodate(page); 362 /* 363 * No need to use i_size_read() here, the i_size 364 * cannot change under us because we hold the i_mutex. 365 */ 366 if (pos > inode->i_size) 367 i_size_write(inode, pos); 368 set_page_dirty(page); 369 return 0; 370} 371 | 374int simple_commit_write(struct file *file, struct page *page, 375 unsigned from, unsigned to) 376{ 377 struct inode *inode = page->mapping->host; 378 loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; 379 380 if (!PageUptodate(page)) 381 SetPageUptodate(page); 382 /* 383 * No need to use i_size_read() here, the i_size 384 * cannot change under us because we hold the i_mutex. 385 */ 386 if (pos > inode->i_size) 387 i_size_write(inode, pos); 388 set_page_dirty(page); 389 return 0; 390} 391 |
392int simple_write_end(struct file *file, struct address_space *mapping, 393 loff_t pos, unsigned len, unsigned copied, 394 struct page *page, void *fsdata) 395{ 396 unsigned from = pos & (PAGE_CACHE_SIZE - 1); 397 398 /* zero the stale part of the page if we did a short copy */ 399 if (copied < len) { 400 void *kaddr = kmap_atomic(page, KM_USER0); 401 memset(kaddr + from + copied, 0, len - copied); 402 flush_dcache_page(page); 403 kunmap_atomic(kaddr, KM_USER0); 404 } 405 406 simple_commit_write(file, page, from, from+copied); 407 408 unlock_page(page); 409 page_cache_release(page); 410 411 return copied; 412} 413 |
|
372/* 373 * the inodes created here are not hashed. If you use iunique to generate 374 * unique inode values later for this filesystem, then you must take care 375 * to pass it an appropriate max_reserved value to avoid collisions. 376 */ 377int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files) 378{ 379 struct inode *inode; --- 257 unchanged lines hidden (view full) --- 637} 638 639EXPORT_SYMBOL(dcache_dir_close); 640EXPORT_SYMBOL(dcache_dir_lseek); 641EXPORT_SYMBOL(dcache_dir_open); 642EXPORT_SYMBOL(dcache_readdir); 643EXPORT_SYMBOL(generic_read_dir); 644EXPORT_SYMBOL(get_sb_pseudo); | 414/* 415 * the inodes created here are not hashed. If you use iunique to generate 416 * unique inode values later for this filesystem, then you must take care 417 * to pass it an appropriate max_reserved value to avoid collisions. 418 */ 419int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files) 420{ 421 struct inode *inode; --- 257 unchanged lines hidden (view full) --- 679} 680 681EXPORT_SYMBOL(dcache_dir_close); 682EXPORT_SYMBOL(dcache_dir_lseek); 683EXPORT_SYMBOL(dcache_dir_open); 684EXPORT_SYMBOL(dcache_readdir); 685EXPORT_SYMBOL(generic_read_dir); 686EXPORT_SYMBOL(get_sb_pseudo); |
687EXPORT_SYMBOL(simple_write_begin); 688EXPORT_SYMBOL(simple_write_end); |
|
645EXPORT_SYMBOL(simple_commit_write); 646EXPORT_SYMBOL(simple_dir_inode_operations); 647EXPORT_SYMBOL(simple_dir_operations); 648EXPORT_SYMBOL(simple_empty); 649EXPORT_SYMBOL(d_alloc_name); 650EXPORT_SYMBOL(simple_fill_super); 651EXPORT_SYMBOL(simple_getattr); 652EXPORT_SYMBOL(simple_link); --- 18 unchanged lines hidden --- | 689EXPORT_SYMBOL(simple_commit_write); 690EXPORT_SYMBOL(simple_dir_inode_operations); 691EXPORT_SYMBOL(simple_dir_operations); 692EXPORT_SYMBOL(simple_empty); 693EXPORT_SYMBOL(d_alloc_name); 694EXPORT_SYMBOL(simple_fill_super); 695EXPORT_SYMBOL(simple_getattr); 696EXPORT_SYMBOL(simple_link); --- 18 unchanged lines hidden --- |