patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / fs / ntfs / file.c
1 /*
2  * file.c - NTFS kernel file operations. Part of the Linux-NTFS project.
3  *
4  * Copyright (c) 2001-2004 Anton Altaparmakov
5  *
6  * This program/include file is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as published
8  * by the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program/include file is distributed in the hope that it will be
12  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program (in the main directory of the Linux-NTFS
18  * distribution in the file COPYING); if not, write to the Free Software
19  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "ntfs.h"
23
24 /**
25  * ntfs_file_open - called when an inode is about to be opened
26  * @vi:         inode to be opened
27  * @filp:       file structure describing the inode
28  *
29  * Limit file size to the page cache limit on architectures where unsigned long
30  * is 32-bits. This is the most we can do for now without overflowing the page
31  * cache page index. Doing it this way means we don't run into problems because
32  * of existing too large files. It would be better to allow the user to read
33  * the beginning of the file but I doubt very much anyone is going to hit this
34  * check on a 32-bit architecture, so there is no point in adding the extra
35  * complexity required to support this.
36  *
37  * On 64-bit architectures, the check is hopefully optimized away by the
38  * compiler.
39  *
40  * After the check passes, just call generic_file_open() to do its work.
41  */
42 static int ntfs_file_open(struct inode *vi, struct file *filp)
43 {
44         if (sizeof(unsigned long) < 8) {
45                 if (vi->i_size > MAX_LFS_FILESIZE)
46                         return -EFBIG;
47         }
48         return generic_file_open(vi, filp);
49 }
50
51 struct file_operations ntfs_file_ops = {
52         .llseek         = generic_file_llseek,  /* Seek inside file. */
53         .read           = generic_file_read,    /* Read from file. */
54 #ifdef NTFS_RW
55         .write          = generic_file_write,   /* Write to a file. */
56 #endif
57         .mmap           = generic_file_mmap,    /* Mmap file. */
58         .sendfile       = generic_file_sendfile,/* Zero-copy data send with the
59                                                    data source being on the
60                                                    ntfs partition. We don't
61                                                    need to care about the data
62                                                    destination. */
63         .open           = ntfs_file_open,       /* Open file. */
64 };
65
66 struct inode_operations ntfs_file_inode_ops = {
67 #ifdef NTFS_RW
68         .truncate       = ntfs_truncate,
69         .setattr        = ntfs_setattr,
70 #endif
71 };
72
73 struct file_operations ntfs_empty_file_ops = {};
74
75 struct inode_operations ntfs_empty_inode_ops = {};