cregit-Linux how code gets into the kernel

Release 4.11 fs/hpfs/file.c

Directory: fs/hpfs
/*
 *  linux/fs/hpfs/file.c
 *
 *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
 *
 *  file VFS functions
 */

#include "hpfs_fn.h"
#include <linux/mpage.h>


#define BLOCKS(size) (((size) + 511) >> 9)


static int hpfs_file_release(struct inode *inode, struct file *file) { hpfs_lock(inode->i_sb); hpfs_write_if_changed(inode); hpfs_unlock(inode->i_sb); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2565.79%250.00%
Arnd Bergmann1231.58%125.00%
Al Viro12.63%125.00%
Total38100.00%4100.00%


int hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) { struct inode *inode = file->f_mapping->host; int ret; ret = filemap_write_and_wait_range(file->f_mapping, start, end); if (ret) return ret; return sync_blockdev(inode->i_sb->s_bdev); }

Contributors

PersonTokensPropCommitsCommitProp
Josef Bacik2946.03%125.00%
Mikulas Patocka1930.16%125.00%
Linus Torvalds (pre-git)1523.81%250.00%
Total63100.00%4100.00%

/* * generic_file_read often calls bmap with non-existing sector, * so we must ignore such errors. */
static secno hpfs_bmap(struct inode *inode, unsigned file_secno, unsigned *n_secs) { struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); unsigned n, disk_secno; struct fnode *fnode; struct buffer_head *bh; if (BLOCKS(hpfs_i(inode)->mmu_private) <= file_secno) return 0; n = file_secno - hpfs_inode->i_file_sec; if (n < hpfs_inode->i_n_secs) { *n_secs = hpfs_inode->i_n_secs - n; return hpfs_inode->i_disk_sec + n; } if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0; disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh); if (disk_secno == -1) return 0; if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0; n = file_secno - hpfs_inode->i_file_sec; if (n < hpfs_inode->i_n_secs) { *n_secs = hpfs_inode->i_n_secs - n; return hpfs_inode->i_disk_sec + n; } *n_secs = 1; return disk_secno; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)13062.50%120.00%
Mikulas Patocka5425.96%120.00%
Linus Torvalds2311.06%240.00%
Al Viro10.48%120.00%
Total208100.00%5100.00%


void hpfs_truncate(struct inode *i) { if (IS_IMMUTABLE(i)) return /*-EPERM*/; hpfs_lock_assert(i->i_sb); hpfs_i(i)->i_n_secs = 0; i->i_blocks = 1 + ((i->i_size + 511) >> 9); hpfs_i(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); hpfs_i(i)->i_n_secs = 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)8177.88%342.86%
Al Viro109.62%114.29%
Linus Torvalds76.73%114.29%
Arnd Bergmann54.81%114.29%
Mikulas Patocka10.96%114.29%
Total104100.00%7100.00%


static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { int r; secno s; unsigned n_secs; hpfs_lock(inode->i_sb); s = hpfs_bmap(inode, iblock, &n_secs); if (s) { if (bh_result->b_size >> 9 < n_secs) n_secs = bh_result->b_size >> 9; n_secs = hpfs_search_hotfix_map_for_range(inode->i_sb, s, n_secs); if (unlikely(!n_secs)) { s = hpfs_search_hotfix_map(inode->i_sb, s); n_secs = 1; } map_bh(bh_result, inode->i_sb, s); bh_result->b_size = n_secs << 9; goto ret_0; } if (!create) goto ret_0; if (iblock<<9 != hpfs_i(inode)->mmu_private) { BUG(); r = -EIO; goto ret_r; } 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); r = -ENOSPC; goto ret_r; } inode->i_blocks++; hpfs_i(inode)->mmu_private += 512; set_buffer_new(bh_result); map_bh(bh_result, inode->i_sb, hpfs_search_hotfix_map(inode->i_sb, s)); ret_0: r = 0; ret_r: hpfs_unlock(inode->i_sb); return r; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)13146.79%433.33%
Mikulas Patocka12143.21%325.00%
Linus Torvalds248.57%325.00%
Andrew Morton31.07%18.33%
Al Viro10.36%18.33%
Total280100.00%12100.00%


static int hpfs_readpage(struct file *file, struct page *page) { return mpage_readpage(page, hpfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Mikulas Patocka24100.00%1100.00%
Total24100.00%1100.00%


static int hpfs_writepage(struct page *page, struct writeback_control *wbc) { return block_write_full_page(page, hpfs_get_block, wbc); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1973.08%480.00%
Andrew Morton726.92%120.00%
Total26100.00%5100.00%


static int hpfs_readpages(struct file *file, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { return mpage_readpages(mapping, pages, nr_pages, hpfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Mikulas Patocka2261.11%125.00%
Linus Torvalds (pre-git)1438.89%375.00%
Total36100.00%4100.00%


static int hpfs_writepages(struct address_space *mapping, struct writeback_control *wbc) { return mpage_writepages(mapping, wbc, hpfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Mikulas Patocka2180.77%133.33%
Linus Torvalds (pre-git)519.23%266.67%
Total26100.00%3100.00%


static void hpfs_write_failed(struct address_space *mapping, loff_t to) { struct inode *inode = mapping->host; hpfs_lock(inode->i_sb); if (to > inode->i_size) { truncate_pagecache(inode, inode->i_size); hpfs_truncate(inode); } hpfs_unlock(inode->i_sb); }

Contributors

PersonTokensPropCommitsCommitProp
Marco Stornelli4777.05%150.00%
Mikulas Patocka1422.95%150.00%
Total61100.00%2100.00%


static int hpfs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) { int ret; *pagep = NULL; ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, hpfs_get_block, &hpfs_i(mapping->host)->mmu_private); if (unlikely(ret)) hpfs_write_failed(mapping, pos + len); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Nicholas Piggin3638.30%112.50%
Linus Torvalds (pre-git)3132.98%450.00%
Christoph Hellwig2122.34%112.50%
Marco Stornelli33.19%112.50%
Linus Torvalds33.19%112.50%
Total94100.00%8100.00%


static int hpfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *pagep, void *fsdata) { struct inode *inode = mapping->host; int err; err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata); if (err < len) hpfs_write_failed(mapping, pos + len); if (!(err < 0)) { /* make sure we write it on close, if not earlier */ hpfs_lock(inode->i_sb); hpfs_i(inode)->i_dirty = 1; hpfs_unlock(inode->i_sb); } return err; }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro118100.00%1100.00%
Total118100.00%1100.00%


static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block) { return generic_block_bmap(mapping, block, hpfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2291.67%480.00%
Andrew Morton28.33%120.00%
Total24100.00%5100.00%


static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len) { return generic_block_fiemap(inode, fieinfo, start, len, hpfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Mikulas Patocka36100.00%1100.00%
Total36100.00%1100.00%

const struct address_space_operations hpfs_aops = { .readpage = hpfs_readpage, .writepage = hpfs_writepage, .readpages = hpfs_readpages, .writepages = hpfs_writepages, .write_begin = hpfs_write_begin, .write_end = hpfs_write_end, .bmap = _hpfs_bmap }; const struct file_operations hpfs_file_ops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .release = hpfs_file_release, .fsync = hpfs_file_fsync, .splice_read = generic_file_splice_read, .unlocked_ioctl = hpfs_ioctl, }; const struct inode_operations hpfs_file_iops = { .setattr = hpfs_setattr, .fiemap = hpfs_fiemap, };

Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)49539.32%820.51%
Mikulas Patocka33526.61%717.95%
Al Viro17714.06%512.82%
Linus Torvalds645.08%410.26%
Marco Stornelli503.97%12.56%
Nicholas Piggin393.10%12.56%
Josef Bacik292.30%12.56%
Christoph Hellwig231.83%37.69%
Arnd Bergmann171.35%12.56%
Andrew Morton120.95%37.69%
Art Haas100.79%12.56%
Badari Pulavarty40.32%12.56%
Jens Axboe20.16%12.56%
Arjan van de Ven20.16%25.13%
Total1259100.00%39100.00%
Directory: fs/hpfs
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.