This source file includes following definitions.
- nfs_put_super
- nfs_read_super
- nfs_statfs
- nfs_fhget
- nfs_notify_change
1
2
3
4
5
6
7
8
9 #include <asm/system.h>
10 #include <asm/segment.h>
11
12 #include <linux/sched.h>
13 #include <linux/nfs_fs.h>
14 #include <linux/kernel.h>
15 #include <linux/mm.h>
16 #include <linux/string.h>
17 #include <linux/stat.h>
18 #include <linux/errno.h>
19 #include <linux/locks.h>
20
21 extern int close_fp(struct file *filp);
22
23 static int nfs_notify_change(struct inode *);
24 static void nfs_put_super(struct super_block *);
25 static void nfs_statfs(struct super_block *, struct statfs *);
26
27 static struct super_operations nfs_sops = {
28 NULL,
29 nfs_notify_change,
30 NULL,
31 NULL,
32 nfs_put_super,
33 NULL,
34 nfs_statfs
35 };
36
37 void nfs_put_super(struct super_block *sb)
38 {
39 close_fp(sb->u.nfs_sb.s_server.file);
40 lock_super(sb);
41 sb->s_dev = 0;
42 unlock_super(sb);
43 }
44
45
46
47
48
49
50
51
52
53 struct super_block *nfs_read_super(struct super_block *sb, void *raw_data)
54 {
55 struct nfs_mount_data *data = (struct nfs_mount_data *) raw_data;
56 struct nfs_server *server;
57 unsigned int fd;
58 struct file *filp;
59 dev_t dev = sb->s_dev;
60
61 if (!data) {
62 printk("nfs_read_super: missing data argument\n");
63 sb->s_dev = 0;
64 return NULL;
65 }
66 fd = data->fd;
67 if (data->version != NFS_MOUNT_VERSION) {
68 printk("nfs warning: mount version %s than kernel\n",
69 data->version < NFS_MOUNT_VERSION ? "older" : "newer");
70 }
71 if (fd >= NR_OPEN || !(filp = current->filp[fd])) {
72 printk("nfs_read_super: invalid file descriptor\n");
73 sb->s_dev = 0;
74 return NULL;
75 }
76 if (!S_ISSOCK(filp->f_inode->i_mode)) {
77 printk("nfs_read_super: not a socket\n");
78 sb->s_dev = 0;
79 return NULL;
80 }
81 filp->f_count++;
82 lock_super(sb);
83 sb->s_blocksize = 1024;
84 sb->s_magic = NFS_SUPER_MAGIC;
85 sb->s_dev = dev;
86 sb->s_op = &nfs_sops;
87 server = &sb->u.nfs_sb.s_server;
88 server->file = filp;
89 server->lock = 0;
90 server->wait = NULL;
91 server->flags = data->flags;
92 server->rsize = data->rsize;
93 if (server->rsize <= 0)
94 server->rsize = NFS_DEF_FILE_IO_BUFFER_SIZE;
95 else if (server->rsize >= NFS_MAX_FILE_IO_BUFFER_SIZE)
96 server->rsize = NFS_MAX_FILE_IO_BUFFER_SIZE;
97 server->wsize = data->wsize;
98 if (server->wsize <= 0)
99 server->wsize = NFS_DEF_FILE_IO_BUFFER_SIZE;
100 else if (server->wsize >= NFS_MAX_FILE_IO_BUFFER_SIZE)
101 server->wsize = NFS_MAX_FILE_IO_BUFFER_SIZE;
102 server->timeo = data->timeo*HZ/10;
103 server->retrans = data->retrans;
104 server->acregmin = data->acregmin*HZ;
105 server->acregmax = data->acregmax*HZ;
106 server->acdirmin = data->acdirmin*HZ;
107 server->acdirmax = data->acdirmax*HZ;
108 strcpy(server->hostname, data->hostname);
109 sb->u.nfs_sb.s_root = data->root;
110 unlock_super(sb);
111 if (!(sb->s_mounted = nfs_fhget(sb, &data->root, NULL))) {
112 sb->s_dev = 0;
113 printk("nfs_read_super: get root inode failed\n");
114 return NULL;
115 }
116 return sb;
117 }
118
119 void nfs_statfs(struct super_block *sb, struct statfs *buf)
120 {
121 int error;
122 struct nfs_fsinfo res;
123
124 put_fs_long(NFS_SUPER_MAGIC, &buf->f_type);
125 error = nfs_proc_statfs(&sb->u.nfs_sb.s_server, &sb->u.nfs_sb.s_root,
126 &res);
127 if (error) {
128 if (error != -EINTR)
129 printk("nfs_statfs: statfs error = %d\n", -error);
130 res.bsize = res.blocks = res.bfree = res.bavail = 0;
131 }
132 put_fs_long(res.bsize, &buf->f_bsize);
133 put_fs_long(res.blocks, &buf->f_blocks);
134 put_fs_long(res.bfree, &buf->f_bfree);
135 put_fs_long(res.bavail, &buf->f_bavail);
136 put_fs_long(0, &buf->f_files);
137 put_fs_long(0, &buf->f_ffree);
138 }
139
140
141
142
143
144
145
146
147
148
149 struct inode *nfs_fhget(struct super_block *sb, struct nfs_fh *fhandle,
150 struct nfs_fattr *fattr)
151 {
152 struct nfs_fattr newfattr;
153 int error;
154 struct inode *inode;
155
156 if (!sb) {
157 printk("nfs_fhget: super block is NULL\n");
158 return NULL;
159 }
160 if (!fattr) {
161 error = nfs_proc_getattr(&sb->u.nfs_sb.s_server, fhandle,
162 &newfattr);
163 if (error) {
164 printk("nfs_fhget: getattr error = %d\n", -error);
165 return NULL;
166 }
167 fattr = &newfattr;
168 }
169 if (!(inode = iget(sb, fattr->fileid))) {
170 printk("nfs_fhget: iget failed\n");
171 return NULL;
172 }
173 if (inode->i_dev == sb->s_dev) {
174 if (inode->i_ino != fattr->fileid) {
175 printk("nfs_fhget: unexpected inode from iget\n");
176 return inode;
177 }
178 *NFS_FH(inode) = *fhandle;
179 nfs_refresh_inode(inode, fattr);
180 }
181 return inode;
182 }
183
184 int nfs_notify_change(struct inode *inode)
185 {
186 struct nfs_sattr sattr;
187 struct nfs_fattr fattr;
188 int error;
189
190 sattr.mode = inode->i_mode;
191 sattr.uid = inode->i_uid;
192 sattr.gid = inode->i_gid;
193 sattr.size = S_ISREG(inode->i_mode) ? inode->i_size : -1;
194 sattr.mtime.seconds = inode->i_mtime;
195 sattr.mtime.useconds = 0;
196 sattr.atime.seconds = inode->i_atime;
197 sattr.atime.useconds = 0;
198 error = nfs_proc_setattr(NFS_SERVER(inode), NFS_FH(inode),
199 &sattr, &fattr);
200 if (!error)
201 nfs_refresh_inode(inode, &fattr);
202 inode->i_dirt = 0;
203 return error;
204 }
205