~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to fs/xfs/linux-2.6/xfs_iops.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 */
18
18
#include "xfs.h"
19
19
#include "xfs_fs.h"
 
20
#include "xfs_acl.h"
20
21
#include "xfs_bit.h"
21
22
#include "xfs_log.h"
22
23
#include "xfs_inum.h"
51
52
#include <linux/capability.h>
52
53
#include <linux/xattr.h>
53
54
#include <linux/namei.h>
 
55
#include <linux/posix_acl.h>
54
56
#include <linux/security.h>
55
57
#include <linux/falloc.h>
56
58
#include <linux/fiemap.h>
202
204
{
203
205
        struct inode    *inode;
204
206
        struct xfs_inode *ip = NULL;
205
 
        xfs_acl_t       *default_acl = NULL;
 
207
        struct posix_acl *default_acl = NULL;
206
208
        struct xfs_name name;
207
 
        int (*test_default_acl)(struct inode *) = _ACL_DEFAULT_EXISTS;
208
209
        int             error;
209
210
 
210
211
        /*
211
212
         * Irix uses Missed'em'V split, but doesn't want to see
212
213
         * the upper 5 bits of (14bit) major.
213
214
         */
214
 
        if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
215
 
                return -EINVAL;
216
 
 
217
 
        if (test_default_acl && test_default_acl(dir)) {
218
 
                if (!_ACL_ALLOC(default_acl)) {
219
 
                        return -ENOMEM;
220
 
                }
221
 
                if (!_ACL_GET_DEFAULT(dir, default_acl)) {
222
 
                        _ACL_FREE(default_acl);
223
 
                        default_acl = NULL;
224
 
                }
225
 
        }
226
 
 
227
 
        xfs_dentry_to_name(&name, dentry);
228
 
 
229
 
        if (IS_POSIXACL(dir) && !default_acl)
230
 
                mode &= ~current->fs->umask;
231
 
 
232
 
        switch (mode & S_IFMT) {
233
 
        case S_IFCHR:
234
 
        case S_IFBLK:
235
 
        case S_IFIFO:
236
 
        case S_IFSOCK:
 
215
        if (S_ISCHR(mode) || S_ISBLK(mode)) {
 
216
                if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
 
217
                        return -EINVAL;
237
218
                rdev = sysv_encode_dev(rdev);
238
 
        case S_IFREG:
239
 
                error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
240
 
                break;
241
 
        case S_IFDIR:
242
 
                error = xfs_mkdir(XFS_I(dir), &name, mode, &ip, NULL);
243
 
                break;
244
 
        default:
245
 
                error = EINVAL;
246
 
                break;
247
 
        }
248
 
 
 
219
        } else {
 
220
                rdev = 0;
 
221
        }
 
222
 
 
223
        if (IS_POSIXACL(dir)) {
 
224
                default_acl = xfs_get_acl(dir, ACL_TYPE_DEFAULT);
 
225
                if (IS_ERR(default_acl))
 
226
                        return -PTR_ERR(default_acl);
 
227
 
 
228
                if (!default_acl)
 
229
                        mode &= ~current_umask();
 
230
        }
 
231
 
 
232
        xfs_dentry_to_name(&name, dentry);
 
233
        error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
249
234
        if (unlikely(error))
250
235
                goto out_free_acl;
251
236
 
256
241
                goto out_cleanup_inode;
257
242
 
258
243
        if (default_acl) {
259
 
                error = _ACL_INHERIT(inode, mode, default_acl);
 
244
                error = -xfs_inherit_acl(inode, default_acl);
260
245
                if (unlikely(error))
261
246
                        goto out_cleanup_inode;
262
 
                _ACL_FREE(default_acl);
 
247
                posix_acl_release(default_acl);
263
248
        }
264
249
 
265
250
 
269
254
 out_cleanup_inode:
270
255
        xfs_cleanup_inode(dir, inode, dentry);
271
256
 out_free_acl:
272
 
        if (default_acl)
273
 
                _ACL_FREE(default_acl);
 
257
        posix_acl_release(default_acl);
274
258
        return -error;
275
259
}
276
260
 
416
400
        mode_t          mode;
417
401
 
418
402
        mode = S_IFLNK |
419
 
                (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
 
403
                (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);
420
404
        xfs_dentry_to_name(&name, dentry);
421
405
 
422
406
        error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
500
484
                kfree(s);
501
485
}
502
486
 
503
 
#ifdef CONFIG_XFS_POSIX_ACL
504
 
STATIC int
505
 
xfs_check_acl(
506
 
        struct inode            *inode,
507
 
        int                     mask)
508
 
{
509
 
        struct xfs_inode        *ip = XFS_I(inode);
510
 
        int                     error;
511
 
 
512
 
        xfs_itrace_entry(ip);
513
 
 
514
 
        if (XFS_IFORK_Q(ip)) {
515
 
                error = xfs_acl_iaccess(ip, mask, NULL);
516
 
                if (error != -1)
517
 
                        return -error;
518
 
        }
519
 
 
520
 
        return -EAGAIN;
521
 
}
522
 
 
523
487
STATIC int
524
488
xfs_vn_permission(
525
489
        struct inode            *inode,
527
491
{
528
492
        return generic_permission(inode, mask, xfs_check_acl);
529
493
}
530
 
#else
531
 
#define xfs_vn_permission NULL
532
 
#endif
533
494
 
534
495
STATIC int
535
496
xfs_vn_getattr(
553
514
        stat->uid = ip->i_d.di_uid;
554
515
        stat->gid = ip->i_d.di_gid;
555
516
        stat->ino = ip->i_ino;
556
 
#if XFS_BIG_INUMS
557
 
        stat->ino += mp->m_inoadd;
558
 
#endif
559
517
        stat->atime = inode->i_atime;
560
518
        stat->mtime.tv_sec = ip->i_d.di_mtime.t_sec;
561
519
        stat->mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;