~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to ubuntu/aufs/vfsub.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
/* ---------------------------------------------------------------------- */
52
52
 
53
 
static int au_conv_oflags(int flags)
54
 
{
55
 
        int mask = 0;
56
 
 
57
 
#ifdef CONFIG_IMA
58
 
        fmode_t fmode;
59
 
 
60
 
        /* mask = MAY_OPEN; */
61
 
        fmode = OPEN_FMODE(flags);
62
 
        if (fmode & FMODE_READ)
63
 
                mask |= MAY_READ;
64
 
        if ((fmode & FMODE_WRITE)
65
 
            || (flags & O_TRUNC))
66
 
                mask |= MAY_WRITE;
67
 
        /*
68
 
         * if (flags & O_APPEND)
69
 
         *      mask |= MAY_APPEND;
70
 
         */
71
 
        if (flags & vfsub_fmode_to_uint(FMODE_EXEC))
72
 
                mask |= MAY_EXEC;
73
 
 
74
 
        AuDbg("flags 0x%x, mask 0x%x\n", flags, mask);
75
 
#endif
76
 
 
77
 
        return mask;
78
 
}
79
 
 
80
53
struct file *vfsub_dentry_open(struct path *path, int flags)
81
54
{
82
55
        struct file *file;
83
 
        int err;
84
56
 
85
57
        path_get(path);
86
58
        file = dentry_open(path->dentry, path->mnt,
87
 
                           flags /* | vfsub_fmode_to_uint(FMODE_NONOTIFY) */,
 
59
                           flags /* | __FMODE_NONOTIFY */,
88
60
                           current_cred());
89
 
        if (IS_ERR(file))
90
 
                goto out;
 
61
        if (!IS_ERR_OR_NULL(file)
 
62
            && (file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
 
63
                i_readcount_inc(path->dentry->d_inode);
91
64
 
92
 
        err = ima_file_check(file, au_conv_oflags(flags));
93
 
        if (unlikely(err)) {
94
 
                fput(file);
95
 
                file = ERR_PTR(err);
96
 
        }
97
 
out:
98
65
        return file;
99
66
}
100
67
 
102
69
{
103
70
        struct file *file;
104
71
 
 
72
        lockdep_off();
105
73
        file = filp_open(path,
106
 
                         oflags /* | vfsub_fmode_to_uint(FMODE_NONOTIFY) */,
 
74
                         oflags /* | __FMODE_NONOTIFY */,
107
75
                         mode);
 
76
        lockdep_on();
108
77
        if (IS_ERR(file))
109
78
                goto out;
110
79
        vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
163
132
        return path.dentry;
164
133
}
165
134
 
 
135
/*
 
136
 * this is "VFS:__lookup_one_len()" which was removed and merged into
 
137
 * VFS:lookup_one_len() by the commit.
 
138
 *      6a96ba5 2011-03-14 kill __lookup_one_len()
 
139
 * this function should always be equivalent to the corresponding part in
 
140
 * VFS:lookup_one_len().
 
141
 */
 
142
int vfsub_name_hash(const char *name, struct qstr *this, int len)
 
143
{
 
144
        unsigned long hash;
 
145
        unsigned int c;
 
146
 
 
147
        this->name = name;
 
148
        this->len = len;
 
149
        if (!len)
 
150
                return -EACCES;
 
151
 
 
152
        hash = init_name_hash();
 
153
        while (len--) {
 
154
                c = *(const unsigned char *)name++;
 
155
                if (c == '/' || c == '\0')
 
156
                        return -EACCES;
 
157
                hash = partial_name_hash(c, hash);
 
158
        }
 
159
        this->hash = end_name_hash(hash);
 
160
        return 0;
 
161
}
 
162
 
166
163
/* ---------------------------------------------------------------------- */
167
164
 
168
165
struct dentry *vfsub_lock_rename(struct dentry *d1, struct au_hinode *hdir1,
170
167
{
171
168
        struct dentry *d;
172
169
 
 
170
        lockdep_off();
173
171
        d = lock_rename(d1, d2);
 
172
        lockdep_on();
174
173
        au_hn_suspend(hdir1);
175
174
        if (hdir1 != hdir2)
176
175
                au_hn_suspend(hdir2);
184
183
        au_hn_resume(hdir1);
185
184
        if (hdir1 != hdir2)
186
185
                au_hn_resume(hdir2);
 
186
        lockdep_off();
187
187
        unlock_rename(d1, d2);
 
188
        lockdep_on();
188
189
}
189
190
 
190
191
/* ---------------------------------------------------------------------- */
326
327
        if (unlikely(err))
327
328
                goto out;
328
329
 
 
330
        lockdep_off();
329
331
        err = vfs_link(src_dentry, dir, path->dentry);
 
332
        lockdep_on();
330
333
        if (!err) {
331
334
                struct path tmp = *path;
332
335
                int did;
366
369
        if (unlikely(err))
367
370
                goto out;
368
371
 
 
372
        lockdep_off();
369
373
        err = vfs_rename(src_dir, src_dentry, dir, path->dentry);
 
374
        lockdep_on();
370
375
        if (!err) {
371
376
                int did;
372
377
 
430
435
        if (unlikely(err))
431
436
                goto out;
432
437
 
 
438
        lockdep_off();
433
439
        err = vfs_rmdir(dir, path->dentry);
 
440
        lockdep_on();
434
441
        if (!err) {
435
442
                struct path tmp = {
436
443
                        .dentry = path->dentry->d_parent,
451
458
{
452
459
        ssize_t err;
453
460
 
 
461
        lockdep_off();
454
462
        err = vfs_read(file, ubuf, count, ppos);
 
463
        lockdep_on();
455
464
        if (err >= 0)
456
465
                vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
457
466
        return err;
481
490
{
482
491
        ssize_t err;
483
492
 
 
493
        lockdep_off();
484
494
        err = vfs_write(file, ubuf, count, ppos);
 
495
        lockdep_on();
485
496
        if (err >= 0)
486
497
                vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
487
498
        return err;
510
521
 
511
522
        err = 0;
512
523
        if (file->f_op && file->f_op->flush) {
513
 
                err = file->f_op->flush(file, id);
 
524
                if (!au_test_nfs(file->f_dentry->d_sb))
 
525
                        err = file->f_op->flush(file, id);
 
526
                else {
 
527
                        lockdep_off();
 
528
                        err = file->f_op->flush(file, id);
 
529
                        lockdep_on();
 
530
                }
514
531
                if (!err)
515
532
                        vfsub_update_h_iattr(&file->f_path, /*did*/NULL);
516
533
                /*ignore*/
522
539
{
523
540
        int err;
524
541
 
 
542
        lockdep_off();
525
543
        err = vfs_readdir(file, filldir, arg);
 
544
        lockdep_on();
526
545
        if (err >= 0)
527
546
                vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
528
547
        return err;
534
553
{
535
554
        long err;
536
555
 
 
556
        lockdep_off();
537
557
        err = do_splice_to(in, ppos, pipe, len, flags);
 
558
        lockdep_on();
538
559
        file_accessed(in);
539
560
        if (err >= 0)
540
561
                vfsub_update_h_iattr(&in->f_path, /*did*/NULL); /*ignore*/
546
567
{
547
568
        long err;
548
569
 
 
570
        lockdep_off();
549
571
        err = do_splice_from(pipe, out, ppos, len, flags);
 
572
        lockdep_on();
550
573
        if (err >= 0)
551
574
                vfsub_update_h_iattr(&out->f_path, /*did*/NULL); /*ignore*/
552
575
        return err;
578
601
        err = locks_verify_truncate(h_inode, h_file, length);
579
602
        if (!err)
580
603
                err = security_path_truncate(h_path);
581
 
        if (!err)
 
604
        if (!err) {
 
605
                lockdep_off();
582
606
                err = do_truncate(h_path->dentry, length, attr, h_file);
 
607
                lockdep_on();
 
608
        }
583
609
 
584
610
out_inode:
585
611
        if (!h_file)
746
772
        if (h_inode)
747
773
                ihold(h_inode);
748
774
 
 
775
        lockdep_off();
749
776
        *a->errp = vfs_unlink(a->dir, d);
 
777
        lockdep_on();
750
778
        if (!*a->errp) {
751
779
                struct path tmp = {
752
780
                        .dentry = d->d_parent,