blob: 9f0f8ee8d44d06dec852f0a245afab40c8956497 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
19#include "xfs_fs.h"
Nathan Scotta844f452005-11-02 14:38:42 +110020#include "xfs_bit.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include "xfs_log.h"
Nathan Scotta844f452005-11-02 14:38:42 +110022#include "xfs_inum.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include "xfs_trans.h"
24#include "xfs_sb.h"
25#include "xfs_ag.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include "xfs_dir2.h"
27#include "xfs_alloc.h"
28#include "xfs_dmapi.h"
29#include "xfs_quota.h"
30#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include "xfs_bmap_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110032#include "xfs_alloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "xfs_ialloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include "xfs_dir2_sf.h"
Nathan Scotta844f452005-11-02 14:38:42 +110035#include "xfs_attr_sf.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include "xfs_dinode.h"
37#include "xfs_inode.h"
38#include "xfs_bmap.h"
Nathan Scotta844f452005-11-02 14:38:42 +110039#include "xfs_btree.h"
40#include "xfs_ialloc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include "xfs_rtalloc.h"
42#include "xfs_error.h"
43#include "xfs_itable.h"
44#include "xfs_rw.h"
45#include "xfs_acl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include "xfs_attr.h"
47#include "xfs_buf_item.h"
48#include "xfs_utils.h"
Christoph Hellwig739bfb22007-08-29 10:58:01 +100049#include "xfs_vnodeops.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Randy Dunlap16f7e0f2006-01-11 12:17:46 -080051#include <linux/capability.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/xattr.h>
53#include <linux/namei.h>
Nathan Scott446ada42006-01-11 15:35:44 +110054#include <linux/security.h>
David Chinner3ed65262007-11-23 16:29:25 +110055#include <linux/falloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Nathan Scott4aeb6642005-11-02 11:43:58 +110057/*
Christoph Hellwig42fe2b12006-01-11 15:35:17 +110058 * Bring the atime in the XFS inode uptodate.
59 * Used before logging the inode to disk or when the Linux inode goes away.
60 */
61void
62xfs_synchronize_atime(
63 xfs_inode_t *ip)
64{
Christoph Hellwigaf048192008-03-06 13:46:43 +110065 struct inode *inode = ip->i_vnode;
Christoph Hellwig42fe2b12006-01-11 15:35:17 +110066
Christoph Hellwigaf048192008-03-06 13:46:43 +110067 if (inode) {
68 ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec;
69 ip->i_d.di_atime.t_nsec = (__int32_t)inode->i_atime.tv_nsec;
Christoph Hellwig42fe2b12006-01-11 15:35:17 +110070 }
71}
72
73/*
David Chinner5d51eff2007-11-23 16:29:18 +110074 * If the linux inode exists, mark it dirty.
75 * Used when commiting a dirty inode into a transaction so that
76 * the inode will get written back by the linux code
77 */
78void
79xfs_mark_inode_dirty_sync(
80 xfs_inode_t *ip)
81{
Christoph Hellwigaf048192008-03-06 13:46:43 +110082 struct inode *inode = ip->i_vnode;
David Chinner5d51eff2007-11-23 16:29:18 +110083
Christoph Hellwigaf048192008-03-06 13:46:43 +110084 if (inode)
85 mark_inode_dirty_sync(inode);
David Chinner5d51eff2007-11-23 16:29:18 +110086}
87
88/*
Nathan Scott4aeb6642005-11-02 11:43:58 +110089 * Change the requested timestamp in the given inode.
90 * We don't lock across timestamp updates, and we don't log them but
91 * we do record the fact that there is dirty information in core.
92 *
93 * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG
94 * with XFS_ICHGTIME_ACC to be sure that access time
95 * update will take. Calling first with XFS_ICHGTIME_ACC
96 * and then XFS_ICHGTIME_MOD may fail to modify the access
97 * timestamp if the filesystem is mounted noacctm.
98 */
99void
100xfs_ichgtime(
101 xfs_inode_t *ip,
102 int flags)
103{
Nathan Scottec86dc02006-03-17 17:25:36 +1100104 struct inode *inode = vn_to_inode(XFS_ITOV(ip));
Nathan Scott4aeb6642005-11-02 11:43:58 +1100105 timespec_t tv;
106
Nathan Scott4aeb6642005-11-02 11:43:58 +1100107 nanotime(&tv);
108 if (flags & XFS_ICHGTIME_MOD) {
109 inode->i_mtime = tv;
110 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
111 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
112 }
113 if (flags & XFS_ICHGTIME_ACC) {
114 inode->i_atime = tv;
115 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
116 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
117 }
118 if (flags & XFS_ICHGTIME_CHG) {
119 inode->i_ctime = tv;
120 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
121 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
122 }
123
124 /*
125 * We update the i_update_core field _after_ changing
126 * the timestamps in order to coordinate properly with
127 * xfs_iflush() so that we don't lose timestamp updates.
128 * This keeps us from having to hold the inode lock
129 * while doing this. We use the SYNCHRONIZE macro to
130 * ensure that the compiler does not reorder the update
131 * of i_update_core above the timestamp updates above.
132 */
133 SYNCHRONIZE();
134 ip->i_update_core = 1;
David Chinnercf10e822007-12-07 14:09:11 +1100135 if (!(inode->i_state & I_NEW))
Nathan Scott4aeb6642005-11-02 11:43:58 +1100136 mark_inode_dirty_sync(inode);
137}
138
139/*
140 * Variant on the above which avoids querying the system clock
141 * in situations where we know the Linux inode timestamps have
142 * just been updated (and so we can update our inode cheaply).
Nathan Scott4aeb6642005-11-02 11:43:58 +1100143 */
144void
145xfs_ichgtime_fast(
146 xfs_inode_t *ip,
147 struct inode *inode,
148 int flags)
149{
150 timespec_t *tvp;
151
152 /*
Christoph Hellwig42fe2b12006-01-11 15:35:17 +1100153 * Atime updates for read() & friends are handled lazily now, and
154 * explicit updates must go through xfs_ichgtime()
155 */
156 ASSERT((flags & XFS_ICHGTIME_ACC) == 0);
157
Nathan Scott4aeb6642005-11-02 11:43:58 +1100158 if (flags & XFS_ICHGTIME_MOD) {
159 tvp = &inode->i_mtime;
160 ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec;
161 ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec;
162 }
Nathan Scott4aeb6642005-11-02 11:43:58 +1100163 if (flags & XFS_ICHGTIME_CHG) {
164 tvp = &inode->i_ctime;
165 ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec;
166 ip->i_d.di_ctime.t_nsec = (__int32_t)tvp->tv_nsec;
167 }
168
169 /*
170 * We update the i_update_core field _after_ changing
171 * the timestamps in order to coordinate properly with
172 * xfs_iflush() so that we don't lose timestamp updates.
173 * This keeps us from having to hold the inode lock
174 * while doing this. We use the SYNCHRONIZE macro to
175 * ensure that the compiler does not reorder the update
176 * of i_update_core above the timestamp updates above.
177 */
178 SYNCHRONIZE();
179 ip->i_update_core = 1;
David Chinnercf10e822007-12-07 14:09:11 +1100180 if (!(inode->i_state & I_NEW))
Nathan Scott4aeb6642005-11-02 11:43:58 +1100181 mark_inode_dirty_sync(inode);
182}
183
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185/*
186 * Pull the link count and size up from the xfs inode to the linux inode
187 */
188STATIC void
Nathan Scott416c6d52006-03-14 14:00:51 +1100189xfs_validate_fields(
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000190 struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191{
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000192 struct xfs_inode *ip = XFS_I(inode);
193 loff_t size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000195 /* we're under i_sem so i_size can't change under us */
196 size = XFS_ISIZE(ip);
197 if (i_size_read(inode) != size)
198 i_size_write(inode, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199}
200
201/*
Nathan Scott446ada42006-01-11 15:35:44 +1100202 * Hook in SELinux. This is not quite correct yet, what we really need
203 * here (as we do for default ACLs) is a mechanism by which creation of
204 * these attrs can be journalled at inode creation time (along with the
205 * inode, of course, such that log replay can't cause these to be lost).
206 */
207STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100208xfs_init_security(
Christoph Hellwigaf048192008-03-06 13:46:43 +1100209 struct inode *inode,
Nathan Scott446ada42006-01-11 15:35:44 +1100210 struct inode *dir)
211{
Christoph Hellwigaf048192008-03-06 13:46:43 +1100212 struct xfs_inode *ip = XFS_I(inode);
Nathan Scott446ada42006-01-11 15:35:44 +1100213 size_t length;
214 void *value;
215 char *name;
216 int error;
217
Christoph Hellwigaf048192008-03-06 13:46:43 +1100218 error = security_inode_init_security(inode, dir, &name,
219 &value, &length);
Nathan Scott446ada42006-01-11 15:35:44 +1100220 if (error) {
221 if (error == -EOPNOTSUPP)
222 return 0;
223 return -error;
224 }
225
Christoph Hellwigaf048192008-03-06 13:46:43 +1100226 error = xfs_attr_set(ip, name, value, length, ATTR_SECURE);
Nathan Scott446ada42006-01-11 15:35:44 +1100227 if (!error)
Christoph Hellwigaf048192008-03-06 13:46:43 +1100228 xfs_iflags_set(ip, XFS_IMODIFIED);
Nathan Scott446ada42006-01-11 15:35:44 +1100229
230 kfree(name);
231 kfree(value);
232 return error;
233}
234
Barry Naujok556b8b12008-04-10 12:22:07 +1000235static void
236xfs_dentry_to_name(
237 struct xfs_name *namep,
238 struct dentry *dentry)
239{
240 namep->name = dentry->d_name.name;
241 namep->len = dentry->d_name.len;
242}
243
David Chinner7989cb82007-02-10 18:34:56 +1100244STATIC void
Nathan Scott416c6d52006-03-14 14:00:51 +1100245xfs_cleanup_inode(
Christoph Hellwig739bfb22007-08-29 10:58:01 +1000246 struct inode *dir,
Christoph Hellwigaf048192008-03-06 13:46:43 +1100247 struct inode *inode,
Nathan Scott220b5282006-03-14 13:33:36 +1100248 struct dentry *dentry,
Yingping Lu3a69c7d2006-02-01 12:14:34 +1100249 int mode)
250{
Barry Naujok556b8b12008-04-10 12:22:07 +1000251 struct xfs_name teardown;
Yingping Lu3a69c7d2006-02-01 12:14:34 +1100252
253 /* Oh, the horror.
Nathan Scott220b5282006-03-14 13:33:36 +1100254 * If we can't add the ACL or we fail in
Nathan Scott416c6d52006-03-14 14:00:51 +1100255 * xfs_init_security we must back out.
Yingping Lu3a69c7d2006-02-01 12:14:34 +1100256 * ENOSPC can hit here, among other things.
257 */
Barry Naujok556b8b12008-04-10 12:22:07 +1000258 xfs_dentry_to_name(&teardown, dentry);
Yingping Lu3a69c7d2006-02-01 12:14:34 +1100259
260 if (S_ISDIR(mode))
Barry Naujok556b8b12008-04-10 12:22:07 +1000261 xfs_rmdir(XFS_I(dir), &teardown, XFS_I(inode));
Yingping Lu3a69c7d2006-02-01 12:14:34 +1100262 else
Barry Naujok556b8b12008-04-10 12:22:07 +1000263 xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
Christoph Hellwigaf048192008-03-06 13:46:43 +1100264 iput(inode);
Yingping Lu3a69c7d2006-02-01 12:14:34 +1100265}
266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100268xfs_vn_mknod(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 struct inode *dir,
270 struct dentry *dentry,
271 int mode,
272 dev_t rdev)
273{
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100274 struct inode *inode;
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100275 struct xfs_inode *ip = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 xfs_acl_t *default_acl = NULL;
Barry Naujok556b8b12008-04-10 12:22:07 +1000277 struct xfs_name name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
279 int error;
280
281 /*
282 * Irix uses Missed'em'V split, but doesn't want to see
283 * the upper 5 bits of (14bit) major.
284 */
Nathan Scott220b5282006-03-14 13:33:36 +1100285 if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 return -EINVAL;
287
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100288 if (test_default_acl && test_default_acl(dir)) {
Nathan Scott220b5282006-03-14 13:33:36 +1100289 if (!_ACL_ALLOC(default_acl)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 return -ENOMEM;
Nathan Scott220b5282006-03-14 13:33:36 +1100291 }
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100292 if (!_ACL_GET_DEFAULT(dir, default_acl)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 _ACL_FREE(default_acl);
294 default_acl = NULL;
295 }
296 }
297
Barry Naujok556b8b12008-04-10 12:22:07 +1000298 xfs_dentry_to_name(&name, dentry);
299
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100300 if (IS_POSIXACL(dir) && !default_acl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 mode &= ~current->fs->umask;
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 switch (mode & S_IFMT) {
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100304 case S_IFCHR:
305 case S_IFBLK:
306 case S_IFIFO:
307 case S_IFSOCK:
Christoph Hellwig3e5daf02007-10-11 18:09:12 +1000308 rdev = sysv_encode_dev(rdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 case S_IFREG:
Barry Naujok556b8b12008-04-10 12:22:07 +1000310 error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 break;
312 case S_IFDIR:
Barry Naujok556b8b12008-04-10 12:22:07 +1000313 error = xfs_mkdir(XFS_I(dir), &name, mode, &ip, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 break;
315 default:
316 error = EINVAL;
317 break;
318 }
319
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100320 if (unlikely(error))
321 goto out_free_acl;
Nathan Scott446ada42006-01-11 15:35:44 +1100322
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100323 inode = ip->i_vnode;
324
325 error = xfs_init_security(inode, dir);
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100326 if (unlikely(error))
327 goto out_cleanup_inode;
328
329 if (default_acl) {
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100330 error = _ACL_INHERIT(inode, mode, default_acl);
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100331 if (unlikely(error))
332 goto out_cleanup_inode;
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100333 xfs_iflags_set(ip, XFS_IMODIFIED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 _ACL_FREE(default_acl);
335 }
336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100338 if (S_ISDIR(mode))
339 xfs_validate_fields(inode);
340 d_instantiate(dentry, inode);
341 xfs_validate_fields(dir);
342 return -error;
343
344 out_cleanup_inode:
Christoph Hellwig979ebab2008-03-06 13:46:05 +1100345 xfs_cleanup_inode(dir, inode, dentry, mode);
Christoph Hellwigdb0bb7b2008-03-06 13:44:35 +1100346 out_free_acl:
347 if (default_acl)
348 _ACL_FREE(default_acl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 return -error;
350}
351
352STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100353xfs_vn_create(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 struct inode *dir,
355 struct dentry *dentry,
356 int mode,
357 struct nameidata *nd)
358{
Nathan Scott416c6d52006-03-14 14:00:51 +1100359 return xfs_vn_mknod(dir, dentry, mode, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360}
361
362STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100363xfs_vn_mkdir(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 struct inode *dir,
365 struct dentry *dentry,
366 int mode)
367{
Nathan Scott416c6d52006-03-14 14:00:51 +1100368 return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
371STATIC struct dentry *
Nathan Scott416c6d52006-03-14 14:00:51 +1100372xfs_vn_lookup(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 struct inode *dir,
374 struct dentry *dentry,
375 struct nameidata *nd)
376{
Christoph Hellwigef1f5e72008-03-06 13:46:25 +1100377 struct xfs_inode *cip;
Barry Naujok556b8b12008-04-10 12:22:07 +1000378 struct xfs_name name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 int error;
380
381 if (dentry->d_name.len >= MAXNAMELEN)
382 return ERR_PTR(-ENAMETOOLONG);
383
Barry Naujok556b8b12008-04-10 12:22:07 +1000384 xfs_dentry_to_name(&name, dentry);
Barry Naujok384f3ce2008-05-21 16:58:22 +1000385 error = xfs_lookup(XFS_I(dir), &name, &cip, NULL);
Nathan Scott67fcaa72006-06-09 17:00:52 +1000386 if (unlikely(error)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 if (unlikely(error != ENOENT))
388 return ERR_PTR(-error);
389 d_add(dentry, NULL);
390 return NULL;
391 }
392
Christoph Hellwigef1f5e72008-03-06 13:46:25 +1100393 return d_splice_alias(cip->i_vnode, dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394}
395
Barry Naujok384f3ce2008-05-21 16:58:22 +1000396STATIC struct dentry *
397xfs_vn_ci_lookup(
398 struct inode *dir,
399 struct dentry *dentry,
400 struct nameidata *nd)
401{
402 struct xfs_inode *ip;
403 struct xfs_name xname;
404 struct xfs_name ci_name;
405 struct qstr dname;
406 int error;
407
408 if (dentry->d_name.len >= MAXNAMELEN)
409 return ERR_PTR(-ENAMETOOLONG);
410
411 xfs_dentry_to_name(&xname, dentry);
412 error = xfs_lookup(XFS_I(dir), &xname, &ip, &ci_name);
413 if (unlikely(error)) {
414 if (unlikely(error != ENOENT))
415 return ERR_PTR(-error);
416 d_add(dentry, NULL);
417 return NULL;
418 }
419
420 /* if exact match, just splice and exit */
421 if (!ci_name.name)
422 return d_splice_alias(ip->i_vnode, dentry);
423
424 /* else case-insensitive match... */
425 dname.name = ci_name.name;
426 dname.len = ci_name.len;
427 dentry = d_add_ci(ip->i_vnode, dentry, &dname);
428 kmem_free(ci_name.name);
429 return dentry;
430}
431
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100433xfs_vn_link(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 struct dentry *old_dentry,
435 struct inode *dir,
436 struct dentry *dentry)
437{
Christoph Hellwiga3da7892008-03-06 13:46:12 +1100438 struct inode *inode; /* inode of guy being linked to */
Barry Naujok556b8b12008-04-10 12:22:07 +1000439 struct xfs_name name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 int error;
441
Christoph Hellwiga3da7892008-03-06 13:46:12 +1100442 inode = old_dentry->d_inode;
Barry Naujok556b8b12008-04-10 12:22:07 +1000443 xfs_dentry_to_name(&name, dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Christoph Hellwiga3da7892008-03-06 13:46:12 +1100445 igrab(inode);
Barry Naujok556b8b12008-04-10 12:22:07 +1000446 error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
Nathan Scott97dfd702006-06-27 16:13:46 +1000447 if (unlikely(error)) {
Christoph Hellwiga3da7892008-03-06 13:46:12 +1100448 iput(inode);
449 return -error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 }
Christoph Hellwiga3da7892008-03-06 13:46:12 +1100451
452 xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED);
453 xfs_validate_fields(inode);
454 d_instantiate(dentry, inode);
455 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
458STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100459xfs_vn_unlink(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 struct inode *dir,
461 struct dentry *dentry)
462{
463 struct inode *inode;
Barry Naujok556b8b12008-04-10 12:22:07 +1000464 struct xfs_name name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 int error;
466
467 inode = dentry->d_inode;
Barry Naujok556b8b12008-04-10 12:22:07 +1000468 xfs_dentry_to_name(&name, dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Barry Naujok556b8b12008-04-10 12:22:07 +1000470 error = xfs_remove(XFS_I(dir), &name, XFS_I(inode));
Nathan Scott220b5282006-03-14 13:33:36 +1100471 if (likely(!error)) {
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000472 xfs_validate_fields(dir); /* size needs update */
473 xfs_validate_fields(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 return -error;
476}
477
478STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100479xfs_vn_symlink(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 struct inode *dir,
481 struct dentry *dentry,
482 const char *symname)
483{
Christoph Hellwig3937be52008-03-06 13:46:19 +1100484 struct inode *inode;
485 struct xfs_inode *cip = NULL;
Barry Naujok556b8b12008-04-10 12:22:07 +1000486 struct xfs_name name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 int error;
Christoph Hellwig3e5daf02007-10-11 18:09:12 +1000488 mode_t mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
Christoph Hellwig3e5daf02007-10-11 18:09:12 +1000490 mode = S_IFLNK |
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000491 (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
Barry Naujok556b8b12008-04-10 12:22:07 +1000492 xfs_dentry_to_name(&name, dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
Barry Naujok556b8b12008-04-10 12:22:07 +1000494 error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
Christoph Hellwig3937be52008-03-06 13:46:19 +1100495 if (unlikely(error))
496 goto out;
497
498 inode = cip->i_vnode;
499
500 error = xfs_init_security(inode, dir);
501 if (unlikely(error))
502 goto out_cleanup_inode;
503
504 d_instantiate(dentry, inode);
505 xfs_validate_fields(dir);
506 xfs_validate_fields(inode);
507 return 0;
508
509 out_cleanup_inode:
510 xfs_cleanup_inode(dir, inode, dentry, 0);
511 out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 return -error;
513}
514
515STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100516xfs_vn_rmdir(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 struct inode *dir,
518 struct dentry *dentry)
519{
520 struct inode *inode = dentry->d_inode;
Barry Naujok556b8b12008-04-10 12:22:07 +1000521 struct xfs_name name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 int error;
523
Barry Naujok556b8b12008-04-10 12:22:07 +1000524 xfs_dentry_to_name(&name, dentry);
525
526 error = xfs_rmdir(XFS_I(dir), &name, XFS_I(inode));
Nathan Scott220b5282006-03-14 13:33:36 +1100527 if (likely(!error)) {
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000528 xfs_validate_fields(inode);
529 xfs_validate_fields(dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 }
531 return -error;
532}
533
534STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100535xfs_vn_rename(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 struct inode *odir,
537 struct dentry *odentry,
538 struct inode *ndir,
539 struct dentry *ndentry)
540{
541 struct inode *new_inode = ndentry->d_inode;
Barry Naujok556b8b12008-04-10 12:22:07 +1000542 struct xfs_name oname;
543 struct xfs_name nname;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 int error;
545
Barry Naujok556b8b12008-04-10 12:22:07 +1000546 xfs_dentry_to_name(&oname, odentry);
547 xfs_dentry_to_name(&nname, ndentry);
548
549 error = xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
Christoph Hellwigcfa853e2008-04-22 17:34:06 +1000550 XFS_I(ndir), &nname, new_inode ?
551 XFS_I(new_inode) : NULL);
Nathan Scott220b5282006-03-14 13:33:36 +1100552 if (likely(!error)) {
553 if (new_inode)
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000554 xfs_validate_fields(new_inode);
555 xfs_validate_fields(odir);
Nathan Scott220b5282006-03-14 13:33:36 +1100556 if (ndir != odir)
Christoph Hellwig6572bc22007-09-19 15:27:39 +1000557 xfs_validate_fields(ndir);
Nathan Scott220b5282006-03-14 13:33:36 +1100558 }
Nathan Scott220b5282006-03-14 13:33:36 +1100559 return -error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560}
561
562/*
563 * careful here - this function can get called recursively, so
564 * we need to be very careful about how much stack we use.
565 * uio is kmalloced for this reason...
566 */
Al Viro008b1502005-08-20 00:17:39 +0100567STATIC void *
Nathan Scott416c6d52006-03-14 14:00:51 +1100568xfs_vn_follow_link(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 struct dentry *dentry,
570 struct nameidata *nd)
571{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 char *link;
Christoph Hellwig804c83c2007-08-28 13:59:03 +1000573 int error = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574
Panagiotis Issarisf52720c2006-09-27 01:49:39 -0700575 link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
Christoph Hellwig804c83c2007-08-28 13:59:03 +1000576 if (!link)
577 goto out_err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578
Christoph Hellwig739bfb22007-08-29 10:58:01 +1000579 error = -xfs_readlink(XFS_I(dentry->d_inode), link);
Christoph Hellwig804c83c2007-08-28 13:59:03 +1000580 if (unlikely(error))
581 goto out_kfree;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582
583 nd_set_link(nd, link);
Al Viro008b1502005-08-20 00:17:39 +0100584 return NULL;
Christoph Hellwig804c83c2007-08-28 13:59:03 +1000585
586 out_kfree:
587 kfree(link);
588 out_err:
589 nd_set_link(nd, ERR_PTR(error));
590 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591}
592
Nathan Scottcde410a2005-09-05 11:47:01 +1000593STATIC void
Nathan Scott416c6d52006-03-14 14:00:51 +1100594xfs_vn_put_link(
Nathan Scottcde410a2005-09-05 11:47:01 +1000595 struct dentry *dentry,
596 struct nameidata *nd,
597 void *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598{
Nathan Scottcde410a2005-09-05 11:47:01 +1000599 char *s = nd_get_link(nd);
600
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 if (!IS_ERR(s))
602 kfree(s);
603}
604
605#ifdef CONFIG_XFS_POSIX_ACL
606STATIC int
Christoph Hellwig45767582008-02-05 12:13:24 +1100607xfs_check_acl(
608 struct inode *inode,
609 int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610{
Christoph Hellwig45767582008-02-05 12:13:24 +1100611 struct xfs_inode *ip = XFS_I(inode);
612 int error;
613
614 xfs_itrace_entry(ip);
615
616 if (XFS_IFORK_Q(ip)) {
617 error = xfs_acl_iaccess(ip, mask, NULL);
618 if (error != -1)
619 return -error;
620 }
621
622 return -EAGAIN;
623}
624
625STATIC int
626xfs_vn_permission(
627 struct inode *inode,
Al Viroe6305c42008-07-15 21:03:57 -0400628 int mask)
Christoph Hellwig45767582008-02-05 12:13:24 +1100629{
630 return generic_permission(inode, mask, xfs_check_acl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631}
632#else
Nathan Scott416c6d52006-03-14 14:00:51 +1100633#define xfs_vn_permission NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634#endif
635
636STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100637xfs_vn_getattr(
Christoph Hellwigc43f4082007-10-11 17:46:39 +1000638 struct vfsmount *mnt,
639 struct dentry *dentry,
640 struct kstat *stat)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641{
Christoph Hellwigc43f4082007-10-11 17:46:39 +1000642 struct inode *inode = dentry->d_inode;
643 struct xfs_inode *ip = XFS_I(inode);
644 struct xfs_mount *mp = ip->i_mount;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645
Christoph Hellwigc43f4082007-10-11 17:46:39 +1000646 xfs_itrace_entry(ip);
647
648 if (XFS_FORCED_SHUTDOWN(mp))
649 return XFS_ERROR(EIO);
650
651 stat->size = XFS_ISIZE(ip);
652 stat->dev = inode->i_sb->s_dev;
653 stat->mode = ip->i_d.di_mode;
654 stat->nlink = ip->i_d.di_nlink;
655 stat->uid = ip->i_d.di_uid;
656 stat->gid = ip->i_d.di_gid;
657 stat->ino = ip->i_ino;
658#if XFS_BIG_INUMS
659 stat->ino += mp->m_inoadd;
660#endif
661 stat->atime = inode->i_atime;
662 stat->mtime.tv_sec = ip->i_d.di_mtime.t_sec;
663 stat->mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
664 stat->ctime.tv_sec = ip->i_d.di_ctime.t_sec;
665 stat->ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
666 stat->blocks =
667 XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
668
669
670 switch (inode->i_mode & S_IFMT) {
671 case S_IFBLK:
672 case S_IFCHR:
673 stat->blksize = BLKDEV_IOSIZE;
674 stat->rdev = MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
675 sysv_minor(ip->i_df.if_u2.if_rdev));
676 break;
677 default:
Eric Sandeen71ddabb2007-11-23 16:29:42 +1100678 if (XFS_IS_REALTIME_INODE(ip)) {
Christoph Hellwigc43f4082007-10-11 17:46:39 +1000679 /*
680 * If the file blocks are being allocated from a
681 * realtime volume, then return the inode's realtime
682 * extent size or the realtime volume's extent size.
683 */
684 stat->blksize =
685 xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
686 } else
687 stat->blksize = xfs_preferred_iosize(mp);
688 stat->rdev = 0;
689 break;
Nathan Scott69e23b92006-09-28 11:01:22 +1000690 }
Christoph Hellwigc43f4082007-10-11 17:46:39 +1000691
692 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693}
694
695STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100696xfs_vn_setattr(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 struct dentry *dentry,
698 struct iattr *attr)
699{
700 struct inode *inode = dentry->d_inode;
701 unsigned int ia_valid = attr->ia_valid;
Nathan Scott8285fb52006-06-09 17:07:12 +1000702 bhv_vattr_t vattr = { 0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 int flags = 0;
704 int error;
705
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 if (ia_valid & ATTR_UID) {
707 vattr.va_mask |= XFS_AT_UID;
708 vattr.va_uid = attr->ia_uid;
709 }
710 if (ia_valid & ATTR_GID) {
711 vattr.va_mask |= XFS_AT_GID;
712 vattr.va_gid = attr->ia_gid;
713 }
714 if (ia_valid & ATTR_SIZE) {
715 vattr.va_mask |= XFS_AT_SIZE;
716 vattr.va_size = attr->ia_size;
717 }
718 if (ia_valid & ATTR_ATIME) {
719 vattr.va_mask |= XFS_AT_ATIME;
720 vattr.va_atime = attr->ia_atime;
Nathan Scott8c0b5112006-04-11 15:12:45 +1000721 inode->i_atime = attr->ia_atime;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 }
723 if (ia_valid & ATTR_MTIME) {
724 vattr.va_mask |= XFS_AT_MTIME;
725 vattr.va_mtime = attr->ia_mtime;
726 }
727 if (ia_valid & ATTR_CTIME) {
728 vattr.va_mask |= XFS_AT_CTIME;
729 vattr.va_ctime = attr->ia_ctime;
730 }
731 if (ia_valid & ATTR_MODE) {
732 vattr.va_mask |= XFS_AT_MODE;
733 vattr.va_mode = attr->ia_mode;
734 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
735 inode->i_mode &= ~S_ISGID;
736 }
737
738 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))
739 flags |= ATTR_UTIME;
740#ifdef ATTR_NO_BLOCK
741 if ((ia_valid & ATTR_NO_BLOCK))
742 flags |= ATTR_NONBLOCK;
743#endif
744
Christoph Hellwig739bfb22007-08-29 10:58:01 +1000745 error = xfs_setattr(XFS_I(inode), &vattr, flags, NULL);
Nathan Scott220b5282006-03-14 13:33:36 +1100746 if (likely(!error))
Christoph Hellwig21a62542007-09-19 15:27:49 +1000747 vn_revalidate(vn_from_inode(inode));
Nathan Scott220b5282006-03-14 13:33:36 +1100748 return -error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749}
750
David Chinnerd87dd632008-04-10 12:21:46 +1000751/*
752 * block_truncate_page can return an error, but we can't propagate it
753 * at all here. Leave a complaint + stack trace in the syslog because
754 * this could be bad. If it is bad, we need to propagate the error further.
755 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756STATIC void
Nathan Scott416c6d52006-03-14 14:00:51 +1100757xfs_vn_truncate(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 struct inode *inode)
759{
David Chinnerd87dd632008-04-10 12:21:46 +1000760 int error;
761 error = block_truncate_page(inode->i_mapping, inode->i_size,
762 xfs_get_blocks);
763 WARN_ON(error);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764}
765
766STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100767xfs_vn_setxattr(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 struct dentry *dentry,
769 const char *name,
770 const void *data,
771 size_t size,
772 int flags)
773{
Nathan Scott67fcaa72006-06-09 17:00:52 +1000774 bhv_vnode_t *vp = vn_from_inode(dentry->d_inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 char *attr = (char *)name;
776 attrnames_t *namesp;
777 int xflags = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778
779 namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
780 if (!namesp)
781 return -EOPNOTSUPP;
782 attr += namesp->attr_namelen;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783
784 /* Convert Linux syscall to XFS internal ATTR flags */
785 if (flags & XATTR_CREATE)
786 xflags |= ATTR_CREATE;
787 if (flags & XATTR_REPLACE)
788 xflags |= ATTR_REPLACE;
789 xflags |= namesp->attr_flag;
790 return namesp->attr_set(vp, attr, (void *)data, size, xflags);
791}
792
793STATIC ssize_t
Nathan Scott416c6d52006-03-14 14:00:51 +1100794xfs_vn_getxattr(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 struct dentry *dentry,
796 const char *name,
797 void *data,
798 size_t size)
799{
Nathan Scott67fcaa72006-06-09 17:00:52 +1000800 bhv_vnode_t *vp = vn_from_inode(dentry->d_inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 char *attr = (char *)name;
802 attrnames_t *namesp;
803 int xflags = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804
805 namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
806 if (!namesp)
807 return -EOPNOTSUPP;
808 attr += namesp->attr_namelen;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
810 /* Convert Linux syscall to XFS internal ATTR flags */
811 if (!size) {
812 xflags |= ATTR_KERNOVAL;
813 data = NULL;
814 }
815 xflags |= namesp->attr_flag;
816 return namesp->attr_get(vp, attr, (void *)data, size, xflags);
817}
818
819STATIC ssize_t
Nathan Scott416c6d52006-03-14 14:00:51 +1100820xfs_vn_listxattr(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 struct dentry *dentry,
822 char *data,
823 size_t size)
824{
Nathan Scott67fcaa72006-06-09 17:00:52 +1000825 bhv_vnode_t *vp = vn_from_inode(dentry->d_inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 int error, xflags = ATTR_KERNAMELS;
827 ssize_t result;
828
829 if (!size)
830 xflags |= ATTR_KERNOVAL;
831 xflags |= capable(CAP_SYS_ADMIN) ? ATTR_KERNFULLS : ATTR_KERNORMALS;
832
833 error = attr_generic_list(vp, data, size, xflags, &result);
834 if (error < 0)
835 return error;
836 return result;
837}
838
839STATIC int
Nathan Scott416c6d52006-03-14 14:00:51 +1100840xfs_vn_removexattr(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 struct dentry *dentry,
842 const char *name)
843{
Nathan Scott67fcaa72006-06-09 17:00:52 +1000844 bhv_vnode_t *vp = vn_from_inode(dentry->d_inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 char *attr = (char *)name;
846 attrnames_t *namesp;
847 int xflags = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848
849 namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
850 if (!namesp)
851 return -EOPNOTSUPP;
852 attr += namesp->attr_namelen;
Christoph Hellwig911ee3d2008-05-19 16:34:34 +1000853
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 xflags |= namesp->attr_flag;
855 return namesp->attr_remove(vp, attr, xflags);
856}
857
David Chinner3ed65262007-11-23 16:29:25 +1100858STATIC long
859xfs_vn_fallocate(
860 struct inode *inode,
861 int mode,
862 loff_t offset,
863 loff_t len)
864{
865 long error;
866 loff_t new_size = 0;
867 xfs_flock64_t bf;
868 xfs_inode_t *ip = XFS_I(inode);
869
870 /* preallocation on directories not yet supported */
871 error = -ENODEV;
872 if (S_ISDIR(inode->i_mode))
873 goto out_error;
874
875 bf.l_whence = 0;
876 bf.l_start = offset;
877 bf.l_len = len;
878
879 xfs_ilock(ip, XFS_IOLOCK_EXCL);
880 error = xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf,
881 0, NULL, ATTR_NOLOCK);
882 if (!error && !(mode & FALLOC_FL_KEEP_SIZE) &&
883 offset + len > i_size_read(inode))
884 new_size = offset + len;
885
886 /* Change file size if needed */
887 if (new_size) {
888 bhv_vattr_t va;
889
890 va.va_mask = XFS_AT_SIZE;
891 va.va_size = new_size;
892 error = xfs_setattr(ip, &va, ATTR_NOLOCK, NULL);
893 }
894
895 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
896out_error:
897 return error;
898}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899
Arjan van de Venc5ef1c42007-02-12 00:55:40 -0800900const struct inode_operations xfs_inode_operations = {
Nathan Scott416c6d52006-03-14 14:00:51 +1100901 .permission = xfs_vn_permission,
902 .truncate = xfs_vn_truncate,
903 .getattr = xfs_vn_getattr,
904 .setattr = xfs_vn_setattr,
905 .setxattr = xfs_vn_setxattr,
906 .getxattr = xfs_vn_getxattr,
907 .listxattr = xfs_vn_listxattr,
908 .removexattr = xfs_vn_removexattr,
David Chinner3ed65262007-11-23 16:29:25 +1100909 .fallocate = xfs_vn_fallocate,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910};
911
Arjan van de Venc5ef1c42007-02-12 00:55:40 -0800912const struct inode_operations xfs_dir_inode_operations = {
Nathan Scott416c6d52006-03-14 14:00:51 +1100913 .create = xfs_vn_create,
914 .lookup = xfs_vn_lookup,
915 .link = xfs_vn_link,
916 .unlink = xfs_vn_unlink,
917 .symlink = xfs_vn_symlink,
918 .mkdir = xfs_vn_mkdir,
919 .rmdir = xfs_vn_rmdir,
920 .mknod = xfs_vn_mknod,
921 .rename = xfs_vn_rename,
922 .permission = xfs_vn_permission,
923 .getattr = xfs_vn_getattr,
924 .setattr = xfs_vn_setattr,
925 .setxattr = xfs_vn_setxattr,
926 .getxattr = xfs_vn_getxattr,
927 .listxattr = xfs_vn_listxattr,
928 .removexattr = xfs_vn_removexattr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929};
930
Barry Naujok384f3ce2008-05-21 16:58:22 +1000931const struct inode_operations xfs_dir_ci_inode_operations = {
932 .create = xfs_vn_create,
933 .lookup = xfs_vn_ci_lookup,
934 .link = xfs_vn_link,
935 .unlink = xfs_vn_unlink,
936 .symlink = xfs_vn_symlink,
937 .mkdir = xfs_vn_mkdir,
938 .rmdir = xfs_vn_rmdir,
939 .mknod = xfs_vn_mknod,
940 .rename = xfs_vn_rename,
941 .permission = xfs_vn_permission,
942 .getattr = xfs_vn_getattr,
943 .setattr = xfs_vn_setattr,
944 .setxattr = xfs_vn_setxattr,
945 .getxattr = xfs_vn_getxattr,
946 .listxattr = xfs_vn_listxattr,
947 .removexattr = xfs_vn_removexattr,
948};
949
Arjan van de Venc5ef1c42007-02-12 00:55:40 -0800950const struct inode_operations xfs_symlink_inode_operations = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 .readlink = generic_readlink,
Nathan Scott416c6d52006-03-14 14:00:51 +1100952 .follow_link = xfs_vn_follow_link,
953 .put_link = xfs_vn_put_link,
954 .permission = xfs_vn_permission,
955 .getattr = xfs_vn_getattr,
956 .setattr = xfs_vn_setattr,
957 .setxattr = xfs_vn_setxattr,
958 .getxattr = xfs_vn_getxattr,
959 .listxattr = xfs_vn_listxattr,
960 .removexattr = xfs_vn_removexattr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961};