diff options
Diffstat (limited to 'fs/libfs.c')
| -rw-r--r-- | fs/libfs.c | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/fs/libfs.c b/fs/libfs.c index 0a9da95317f7..62baa0387d6e 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
| @@ -913,6 +913,35 @@ int generic_file_fsync(struct file *file, int datasync) | |||
| 913 | } | 913 | } | 
| 914 | EXPORT_SYMBOL(generic_file_fsync); | 914 | EXPORT_SYMBOL(generic_file_fsync); | 
| 915 | 915 | ||
| 916 | /** | ||
| 917 | * generic_check_addressable - Check addressability of file system | ||
| 918 | * @blocksize_bits: log of file system block size | ||
| 919 | * @num_blocks: number of blocks in file system | ||
| 920 | * | ||
| 921 | * Determine whether a file system with @num_blocks blocks (and a | ||
| 922 | * block size of 2**@blocksize_bits) is addressable by the sector_t | ||
| 923 | * and page cache of the system. Return 0 if so and -EFBIG otherwise. | ||
| 924 | */ | ||
| 925 | int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks) | ||
| 926 | { | ||
| 927 | u64 last_fs_block = num_blocks - 1; | ||
| 928 | u64 last_fs_page = | ||
| 929 | last_fs_block >> (PAGE_CACHE_SHIFT - blocksize_bits); | ||
| 930 | |||
| 931 | if (unlikely(num_blocks == 0)) | ||
| 932 | return 0; | ||
| 933 | |||
| 934 | if ((blocksize_bits < 9) || (blocksize_bits > PAGE_CACHE_SHIFT)) | ||
| 935 | return -EINVAL; | ||
| 936 | |||
| 937 | if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) || | ||
| 938 | (last_fs_page > (pgoff_t)(~0ULL))) { | ||
| 939 | return -EFBIG; | ||
| 940 | } | ||
| 941 | return 0; | ||
| 942 | } | ||
| 943 | EXPORT_SYMBOL(generic_check_addressable); | ||
| 944 | |||
| 916 | /* | 945 | /* | 
| 917 | * No-op implementation of ->fsync for in-memory filesystems. | 946 | * No-op implementation of ->fsync for in-memory filesystems. | 
| 918 | */ | 947 | */ | 
