4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 11 * linux/fs/minix/file.c 13 * Copyright (C) 1991, 1992 Linus Torvalds 15 * ext2 fs regular file handling primitives 17 * 64-bit file support on 64-bit platforms by Jakub Jelinek 18 * (jj@sunsite.ms.mff.cuni.cz) 22 #include <linux/ext2_fs.h> 23 #include <linux/sched.h> 25 static loff_t
ext2_file_lseek(struct file
*, loff_t
,int); 26 static intext2_open_file(struct inode
*,struct file
*); 28 #define EXT2_MAX_SIZE(bits) \ 29 (((EXT2_NDIR_BLOCKS + (1LL << (bits - 2)) + \ 30 (1LL << (bits - 2)) * (1LL << (bits - 2)) + \ 31 (1LL << (bits - 2)) * (1LL << (bits - 2)) * (1LL << (bits - 2))) * \ 34 static long long ext2_max_sizes
[] = { 35 0,0,0,0,0,0,0,0,0,0, 36 EXT2_MAX_SIZE(10),EXT2_MAX_SIZE(11),EXT2_MAX_SIZE(12),EXT2_MAX_SIZE(13) 40 * Make sure the offset never goes beyond the 32-bit mark.. 42 static loff_t
ext2_file_lseek( 47 struct inode
*inode
= file
->f_dentry
->d_inode
; 51 offset
+= inode
->i_size
; 54 offset
+= file
->f_pos
; 58 if(((unsigned long long) offset
>>32) !=0) { 59 if(offset
> ext2_max_sizes
[EXT2_BLOCK_SIZE_BITS(inode
->i_sb
)]) 62 if(offset
!= file
->f_pos
) { 65 file
->f_version
= ++event
; 71 * Called when an inode is released. Note that this is different 72 * from ext2_file_open: open gets called at every open, but release 73 * gets called only when /all/ the files are closed. 75 static intext2_release_file(struct inode
* inode
,struct file
* filp
) 77 if(filp
->f_mode
& FMODE_WRITE
) 78 ext2_discard_prealloc(inode
); 83 * Called when an inode is about to be open. 84 * We use this to disallow opening RW large files on 32bit systems if 85 * the caller didn't specify O_LARGEFILE. On 64bit systems we force 86 * on this flag in sys_open. 88 static intext2_open_file(struct inode
* inode
,struct file
* filp
) 90 if(!(filp
->f_flags
& O_LARGEFILE
) && 91 inode
->i_size
>0x7FFFFFFFLL
) 97 * We have mostly NULL's here: the current defaults are ok for 98 * the ext2 filesystem. 100 struct file_operations ext2_file_operations
= { 101 llseek
: ext2_file_lseek
, 102 read
: generic_file_read
, 103 write
: generic_file_write
, 105 mmap
: generic_file_mmap
, 106 open
: ext2_open_file
, 107 release
: ext2_release_file
, 108 fsync
: ext2_sync_file
, 111 struct inode_operations ext2_file_inode_operations
= { 112 truncate
: ext2_truncate
,