~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs25/dir.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005-2008 Junjiro Okajima
 
3
 *
 
4
 * This program, aufs is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will 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.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 */
 
18
 
 
19
/*
 
20
 * directory operations
 
21
 *
 
22
 * $Id: dir.c,v 1.3 2008/04/28 03:04:12 sfjro Exp $
 
23
 */
 
24
 
 
25
#include <linux/fs_stack.h>
 
26
#include "aufs.h"
 
27
 
 
28
static int reopen_dir(struct file *file)
 
29
{
 
30
        int err;
 
31
        struct dentry *dentry, *h_dentry;
 
32
        aufs_bindex_t bindex, btail, bstart;
 
33
        struct file *h_file;
 
34
 
 
35
        dentry = file->f_dentry;
 
36
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
 
37
        AuDebugOn(!S_ISDIR(dentry->d_inode->i_mode));
 
38
 
 
39
        /* open all hidden dirs */
 
40
        bstart = au_dbstart(dentry);
 
41
#if 1
 
42
        for (bindex = au_fbstart(file); bindex < bstart; bindex++)
 
43
                au_set_h_fptr(file, bindex, NULL);
 
44
#endif
 
45
        au_set_fbstart(file, bstart);
 
46
        btail = au_dbtaildir(dentry);
 
47
#if 1
 
48
        for (bindex = au_fbend(file); btail < bindex; bindex--)
 
49
                au_set_h_fptr(file, bindex, NULL);
 
50
#endif
 
51
        au_set_fbend(file, btail);
 
52
        for (bindex = bstart; bindex <= btail; bindex++) {
 
53
                h_dentry = au_h_dptr(dentry, bindex);
 
54
                if (!h_dentry)
 
55
                        continue;
 
56
                h_file = au_h_fptr(file, bindex);
 
57
                if (h_file) {
 
58
                        AuDebugOn(h_file->f_dentry != h_dentry);
 
59
                        continue;
 
60
                }
 
61
 
 
62
                h_file = au_h_open(dentry, bindex, file->f_flags, file);
 
63
                // unavailable
 
64
                //if (LktrCond) {fput(h_file);
 
65
                //au_br_put(au_sbr(dentry->d_sb, bindex));h_file=ERR_PTR(-1);}
 
66
                err = PTR_ERR(h_file);
 
67
                if (IS_ERR(h_file))
 
68
                        goto out; // close all?
 
69
                //cpup_file_flags(h_file, file);
 
70
                au_set_h_fptr(file, bindex, h_file);
 
71
        }
 
72
        au_update_figen(file);
 
73
        //file->f_ra = h_file->f_ra; //??
 
74
        err = 0;
 
75
 
 
76
 out:
 
77
        AuTraceErr(err);
 
78
        return err;
 
79
}
 
80
 
 
81
static int do_open_dir(struct file *file, int flags)
 
82
{
 
83
        int err;
 
84
        aufs_bindex_t bindex, btail;
 
85
        struct dentry *dentry, *h_dentry;
 
86
        struct file *h_file;
 
87
 
 
88
        dentry = file->f_dentry;
 
89
        LKTRTrace("%.*s, 0x%x\n", AuDLNPair(dentry), flags);
 
90
        AuDebugOn(!dentry->d_inode || !S_ISDIR(dentry->d_inode->i_mode));
 
91
 
 
92
        err = 0;
 
93
        au_set_fvdir_cache(file, NULL);
 
94
        file->f_version = dentry->d_inode->i_version;
 
95
        bindex = au_dbstart(dentry);
 
96
        au_set_fbstart(file, bindex);
 
97
        btail = au_dbtaildir(dentry);
 
98
        au_set_fbend(file, btail);
 
99
        for (; !err && bindex <= btail; bindex++) {
 
100
                h_dentry = au_h_dptr(dentry, bindex);
 
101
                if (!h_dentry)
 
102
                        continue;
 
103
 
 
104
                h_file = au_h_open(dentry, bindex, flags, file);
 
105
                //if (LktrCond) {fput(h_file);
 
106
                //au_br_put(au_sbr(dentry->d_sb, bindex));h_file=ERR_PTR(-1);}
 
107
                if (!IS_ERR(h_file)) {
 
108
                        au_set_h_fptr(file, bindex, h_file);
 
109
                        continue;
 
110
                }
 
111
                err = PTR_ERR(h_file);
 
112
        }
 
113
        au_update_figen(file);
 
114
        //file->f_ra = h_file->f_ra; //??
 
115
        if (!err)
 
116
                return 0; /* success */
 
117
 
 
118
        /* close all */
 
119
        for (bindex = au_fbstart(file); !err && bindex <= btail; bindex++)
 
120
                au_set_h_fptr(file, bindex, NULL);
 
121
        au_set_fbstart(file, -1);
 
122
        au_set_fbend(file, -1);
 
123
        return err;
 
124
}
 
125
 
 
126
static int aufs_open_dir(struct inode *inode, struct file *file)
 
127
{
 
128
        return au_do_open(inode, file, do_open_dir);
 
129
}
 
130
 
 
131
static int aufs_release_dir(struct inode *inode, struct file *file)
 
132
{
 
133
        struct au_vdir *vdir_cache;
 
134
        struct super_block *sb;
 
135
 
 
136
        LKTRTrace("i%lu, %.*s\n", inode->i_ino, AuDLNPair(file->f_dentry));
 
137
 
 
138
        sb = file->f_dentry->d_sb;
 
139
        si_read_lock(sb, !AuLock_FLUSH);
 
140
        fi_write_lock(file);
 
141
        vdir_cache = au_fvdir_cache(file);
 
142
        if (vdir_cache)
 
143
                au_vdir_free(vdir_cache);
 
144
        fi_write_unlock(file);
 
145
        au_finfo_fin(file);
 
146
        si_read_unlock(sb);
 
147
        return 0;
 
148
}
 
149
 
 
150
static int fsync_dir(struct dentry *dentry, int datasync)
 
151
{
 
152
        int err;
 
153
        struct inode *inode;
 
154
        struct super_block *sb;
 
155
        aufs_bindex_t bend, bindex;
 
156
 
 
157
        LKTRTrace("%.*s, %d\n", AuDLNPair(dentry), datasync);
 
158
        DiMustAnyLock(dentry);
 
159
        sb = dentry->d_sb;
 
160
        SiMustAnyLock(sb);
 
161
        inode = dentry->d_inode;
 
162
        IMustLock(inode);
 
163
        IiMustAnyLock(inode);
 
164
 
 
165
        err = 0;
 
166
        bend = au_dbend(dentry);
 
167
        for (bindex = au_dbstart(dentry); !err && bindex <= bend; bindex++) {
 
168
                struct dentry *h_dentry;
 
169
                struct inode *h_inode;
 
170
                struct file_operations *fop;
 
171
 
 
172
                if (au_test_ro(sb, bindex, inode))
 
173
                        continue;
 
174
                h_dentry = au_h_dptr(dentry, bindex);
 
175
                if (!h_dentry)
 
176
                        continue;
 
177
                h_inode = h_dentry->d_inode;
 
178
                if (!h_inode)
 
179
                        continue;
 
180
 
 
181
                /* cf. fs/nsfd/vfs.c and fs/nfsd/nfs4recover.c */
 
182
                //au_hdir_lock(h_inode, inode, bindex);
 
183
                mutex_lock(&h_inode->i_mutex);
 
184
                fop = (void *)h_inode->i_fop;
 
185
                err = filemap_fdatawrite(h_inode->i_mapping);
 
186
                if (!err && fop && fop->fsync)
 
187
                        err = fop->fsync(NULL, h_dentry, datasync);
 
188
                if (!err)
 
189
                        err = filemap_fdatawrite(h_inode->i_mapping);
 
190
                if (!err)
 
191
                        au_update_fuse_h_inode(NULL, h_dentry); /*ignore*/
 
192
                //au_hdir_unlock(h_inode, inode, bindex);
 
193
                mutex_unlock(&h_inode->i_mutex);
 
194
        }
 
195
 
 
196
        AuTraceErr(err);
 
197
        return err;
 
198
}
 
199
 
 
200
/*
 
201
 * @file may be NULL
 
202
 */
 
203
static int aufs_fsync_dir(struct file *file, struct dentry *dentry,
 
204
                          int datasync)
 
205
{
 
206
        int err;
 
207
        struct inode *inode;
 
208
        struct file *h_file;
 
209
        struct super_block *sb;
 
210
        aufs_bindex_t bend, bindex;
 
211
 
 
212
        LKTRTrace("%.*s, %d\n", AuDLNPair(dentry), datasync);
 
213
        inode = dentry->d_inode;
 
214
        IMustLock(inode);
 
215
 
 
216
        err = 0;
 
217
        sb = dentry->d_sb;
 
218
        si_read_lock(sb, !AuLock_FLUSH);
 
219
        if (file) {
 
220
                err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
 
221
                                              /*locked*/1);
 
222
                //err = -1;
 
223
                if (unlikely(err))
 
224
                        goto out;
 
225
        } else
 
226
                di_read_lock_child(dentry, !AuLock_IW);
 
227
 
 
228
        ii_write_lock_child(inode);
 
229
        if (file) {
 
230
                bend = au_fbend(file);
 
231
                for (bindex = au_fbstart(file); !err && bindex <= bend;
 
232
                     bindex++) {
 
233
                        h_file = au_h_fptr(file, bindex);
 
234
                        if (!h_file || au_test_ro(sb, bindex, inode))
 
235
                                continue;
 
236
 
 
237
                        err = -EINVAL;
 
238
                        if (h_file->f_op && h_file->f_op->fsync) {
 
239
                                // todo: try do_fsync() in fs/sync.c
 
240
#if 0 // debug
 
241
                                AuDebugOn(h_file->f_dentry->d_inode
 
242
                                          != au_h_iptr(inode, bindex));
 
243
                                au_hdir_lock(h_file->f_dentry->d_inode, inode,
 
244
                                             bindex);
 
245
#else
 
246
                                mutex_lock(&h_file->f_mapping->host->i_mutex);
 
247
#endif
 
248
                                err = h_file->f_op->fsync
 
249
                                        (h_file, h_file->f_dentry, datasync);
 
250
                                //err = -1;
 
251
                                if (!err)
 
252
                                        au_update_fuse_h_inode
 
253
                                                (h_file->f_vfsmnt,
 
254
                                                 h_file->f_dentry);
 
255
                                /*ignore*/
 
256
#if 0 // debug
 
257
                                au_hdir_unlock(h_file->f_dentry->d_inode, inode,
 
258
                                               bindex);
 
259
#else
 
260
                                mutex_unlock(&h_file->f_mapping->host->i_mutex);
 
261
#endif
 
262
                        }
 
263
                }
 
264
        } else
 
265
                err = fsync_dir(dentry, datasync);
 
266
        au_cpup_attr_timesizes(inode);
 
267
        ii_write_unlock(inode);
 
268
        if (file)
 
269
                fi_write_unlock(file);
 
270
        else
 
271
                di_read_unlock(dentry, !AuLock_IW);
 
272
 
 
273
 out:
 
274
        si_read_unlock(sb);
 
275
        AuTraceErr(err);
 
276
        return err;
 
277
}
 
278
 
 
279
/* ---------------------------------------------------------------------- */
 
280
 
 
281
static int aufs_readdir(struct file *file, void *dirent, filldir_t filldir)
 
282
{
 
283
        int err;
 
284
        struct dentry *dentry;
 
285
        struct inode *inode;
 
286
        struct super_block *sb;
 
287
 
 
288
        dentry = file->f_dentry;
 
289
        LKTRTrace("%.*s, pos %Ld\n", AuDLNPair(dentry), file->f_pos);
 
290
        inode = dentry->d_inode;
 
291
        IMustLock(inode);
 
292
 
 
293
        au_nfsd_lockdep_off();
 
294
        sb = dentry->d_sb;
 
295
        si_read_lock(sb, AuLock_FLUSH);
 
296
        err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
 
297
                                      /*locked*/1);
 
298
        if (unlikely(err))
 
299
                goto out;
 
300
 
 
301
        ii_write_lock_child(inode);
 
302
        err = au_vdir_init(file);
 
303
        if (unlikely(err)) {
 
304
                ii_write_unlock(inode);
 
305
                goto out_unlock;
 
306
        }
 
307
        //DbgVdir(au_fvdir_cache(file));// goto out_unlock;
 
308
 
 
309
        /* nfsd filldir calls lookup_one_len(). */
 
310
        ii_downgrade_lock(inode);
 
311
        err = au_vdir_fill_de(file, dirent, filldir);
 
312
        //DbgVdir(au_fvdir_cache(file));// goto out_unlock;
 
313
 
 
314
        fsstack_copy_attr_atime(inode, au_h_iptr(inode, au_ibstart(inode)));
 
315
        ii_read_unlock(inode);
 
316
 
 
317
 out_unlock:
 
318
        fi_write_unlock(file);
 
319
 out:
 
320
        si_read_unlock(sb);
 
321
        au_nfsd_lockdep_on();
 
322
#if 0 // debug
 
323
        if (LktrCond)
 
324
                igrab(inode);
 
325
#endif
 
326
        AuTraceErr(err);
 
327
        return err;
 
328
}
 
329
 
 
330
/* ---------------------------------------------------------------------- */
 
331
 
 
332
#define AuTestEmpty_WHONLY      1
 
333
#define AuTestEmpty_DLGT        (1 << 1)
 
334
#define AuTestEmpty_DIRPERM1    (1 << 2)
 
335
#define AuTestEmpty_CALLED      (1 << 3)
 
336
#define AuTestEmpty_SHWH        (1 << 4)
 
337
#define au_ftest_testempty(flags, name) ((flags) & AuTestEmpty_##name)
 
338
#define au_fset_testempty(flags, name)  { (flags) |= AuTestEmpty_##name; }
 
339
#define au_fclr_testempty(flags, name)  { (flags) &= ~AuTestEmpty_##name; }
 
340
#ifndef CONFIG_AUFS_DLGT
 
341
#undef AuTestEmpty_DLGT
 
342
#define AuTestEmpty_DLGT        0
 
343
#undef AuTestEmpty_DIRPERM1
 
344
#define AuTestEmpty_DIRPERM1    0
 
345
#endif
 
346
#ifndef CONFIG_AUFS_SHWH
 
347
#undef AuTestEmpty_SHWH
 
348
#define AuTestEmpty_SHWH        0
 
349
#endif
 
350
 
 
351
struct test_empty_arg {
 
352
        struct au_nhash *whlist;
 
353
        unsigned int flags;
 
354
        int err;
 
355
        aufs_bindex_t bindex;
 
356
};
 
357
 
 
358
static int test_empty_cb(void *__arg, const char *__name, int namelen,
 
359
                         loff_t offset, u64 ino, unsigned int d_type)
 
360
{
 
361
        struct test_empty_arg *arg = __arg;
 
362
        char *name = (void *)__name;
 
363
 
 
364
        LKTRTrace("%.*s\n", namelen, name);
 
365
 
 
366
        arg->err = 0;
 
367
        au_fset_testempty(arg->flags, CALLED);
 
368
        //smp_mb();
 
369
        if (name[0] == '.'
 
370
            && (namelen == 1 || (name[1] == '.' && namelen == 2)))
 
371
                return 0; /* success */
 
372
 
 
373
        if (namelen <= AUFS_WH_PFX_LEN
 
374
            || memcmp(name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) {
 
375
                if (au_ftest_testempty(arg->flags, WHONLY)
 
376
                    && !au_nhash_test_known_wh(arg->whlist, name, namelen))
 
377
                        arg->err = -ENOTEMPTY;
 
378
                goto out;
 
379
        }
 
380
 
 
381
        name += AUFS_WH_PFX_LEN;
 
382
        namelen -= AUFS_WH_PFX_LEN;
 
383
        if (!au_nhash_test_known_wh(arg->whlist, name, namelen))
 
384
                arg->err = au_nhash_append_wh
 
385
                        (arg->whlist, name, namelen, ino, d_type, arg->bindex,
 
386
                         au_ftest_testempty(arg->flags, SHWH));
 
387
 
 
388
 out:
 
389
        //smp_mb();
 
390
        AuTraceErr(arg->err);
 
391
        return arg->err;
 
392
}
 
393
 
 
394
static int do_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
 
395
{
 
396
        int err, dlgt;
 
397
        struct file *h_file;
 
398
 
 
399
        LKTRTrace("%.*s, {%p, 0x%x, %d}\n",
 
400
                  AuDLNPair(dentry), arg->whlist, arg->flags, arg->bindex);
 
401
 
 
402
        h_file = au_h_open(dentry, arg->bindex,
 
403
                           O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_LARGEFILE,
 
404
                           /*file*/NULL);
 
405
        err = PTR_ERR(h_file);
 
406
        if (IS_ERR(h_file))
 
407
                goto out;
 
408
        err = 0;
 
409
        if (unlikely(au_opt_test(au_mntflags(dentry->d_sb), UDBA_INOTIFY)
 
410
                     && !h_file->f_dentry->d_inode->i_nlink))
 
411
                goto out_put;
 
412
 
 
413
        dlgt = au_ftest_testempty(arg->flags, DLGT);
 
414
        //h_file->f_pos = 0;
 
415
        do {
 
416
                arg->err = 0;
 
417
                au_fclr_testempty(arg->flags, CALLED);
 
418
                //smp_mb();
 
419
                err = vfsub_readdir(h_file, test_empty_cb, arg, dlgt);
 
420
                if (err >= 0)
 
421
                        err = arg->err;
 
422
        } while (!err && au_ftest_testempty(arg->flags, CALLED));
 
423
 
 
424
 out_put:
 
425
        fput(h_file);
 
426
        au_sbr_put(dentry->d_sb, arg->bindex);
 
427
 out:
 
428
        AuTraceErr(err);
 
429
        return err;
 
430
}
 
431
 
 
432
struct do_test_empty_args {
 
433
        int *errp;
 
434
        struct dentry *dentry;
 
435
        struct test_empty_arg *arg;
 
436
};
 
437
 
 
438
static void call_do_test_empty(void *args)
 
439
{
 
440
        struct do_test_empty_args *a = args;
 
441
        *a->errp = do_test_empty(a->dentry, a->arg);
 
442
}
 
443
 
 
444
static int sio_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
 
445
{
 
446
        int err, wkq_err;
 
447
        struct dentry *h_dentry;
 
448
        struct inode *h_inode;
 
449
 
 
450
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
 
451
        h_dentry = au_h_dptr(dentry, arg->bindex);
 
452
        AuDebugOn(!h_dentry);
 
453
        h_inode = h_dentry->d_inode;
 
454
        AuDebugOn(!h_inode || !S_ISDIR(h_inode->i_mode));
 
455
 
 
456
        mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
 
457
        err = au_test_h_perm_sio(h_inode, MAY_EXEC | MAY_READ,
 
458
                                 au_opt_test_dlgt(au_mntflags(dentry->d_sb)));
 
459
        mutex_unlock(&h_inode->i_mutex);
 
460
        if (!err)
 
461
                err = do_test_empty(dentry, arg);
 
462
        else {
 
463
                struct do_test_empty_args args = {
 
464
                        .errp   = &err,
 
465
                        .dentry = dentry,
 
466
                        .arg    = arg
 
467
                };
 
468
                unsigned int flags = arg->flags;
 
469
                au_fclr_testempty(arg->flags, DLGT);
 
470
                au_fclr_testempty(arg->flags, DIRPERM1);
 
471
                wkq_err = au_wkq_wait(call_do_test_empty, &args, /*dlgt*/0);
 
472
                if (unlikely(wkq_err))
 
473
                        err = wkq_err;
 
474
                arg->flags = flags;
 
475
        }
 
476
 
 
477
        AuTraceErr(err);
 
478
        return err;
 
479
}
 
480
 
 
481
int au_test_empty_lower(struct dentry *dentry)
 
482
{
 
483
        int err;
 
484
        struct inode *inode;
 
485
        struct test_empty_arg arg;
 
486
        struct au_nhash *whlist;
 
487
        aufs_bindex_t bindex, bstart, btail;
 
488
        unsigned int mnt_flags;
 
489
 
 
490
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
 
491
        inode = dentry->d_inode;
 
492
        AuDebugOn(!inode || !S_ISDIR(inode->i_mode));
 
493
 
 
494
        whlist = au_nhash_new(GFP_TEMPORARY);
 
495
        err = PTR_ERR(whlist);
 
496
        if (IS_ERR(whlist))
 
497
                goto out;
 
498
 
 
499
        bstart = au_dbstart(dentry);
 
500
        mnt_flags = au_mntflags(dentry->d_sb);
 
501
        arg.whlist = whlist;
 
502
        arg.flags = 0;
 
503
        if (unlikely(au_opt_test_dlgt(mnt_flags)))
 
504
                au_fset_testempty(arg.flags, DLGT);
 
505
        if (unlikely(au_opt_test(mnt_flags, SHWH)))
 
506
                au_fset_testempty(arg.flags, SHWH);
 
507
        arg.bindex = bstart;
 
508
        err = do_test_empty(dentry, &arg);
 
509
        if (unlikely(err))
 
510
                goto out_whlist;
 
511
 
 
512
        au_fset_testempty(arg.flags, WHONLY);
 
513
        if (unlikely(au_opt_test_dirperm1(mnt_flags)))
 
514
                au_fset_testempty(arg.flags, DIRPERM1);
 
515
        btail = au_dbtaildir(dentry);
 
516
        for (bindex = bstart + 1; !err && bindex <= btail; bindex++) {
 
517
                struct dentry *h_dentry;
 
518
                h_dentry = au_h_dptr(dentry, bindex);
 
519
                if (h_dentry && h_dentry->d_inode) {
 
520
                        AuDebugOn(!S_ISDIR(h_dentry->d_inode->i_mode));
 
521
                        arg.bindex = bindex;
 
522
                        err = do_test_empty(dentry, &arg);
 
523
                }
 
524
        }
 
525
 
 
526
 out_whlist:
 
527
        au_nhash_del(whlist);
 
528
 out:
 
529
        AuTraceErr(err);
 
530
        return err;
 
531
}
 
532
 
 
533
int au_test_empty(struct dentry *dentry, struct au_nhash *whlist)
 
534
{
 
535
        int err;
 
536
        struct inode *inode;
 
537
        struct test_empty_arg arg;
 
538
        aufs_bindex_t bindex, btail;
 
539
 
 
540
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
 
541
        inode = dentry->d_inode;
 
542
        AuDebugOn(!inode || !S_ISDIR(inode->i_mode));
 
543
 
 
544
        err = 0;
 
545
        arg.whlist = whlist;
 
546
        arg.flags = AuTestEmpty_WHONLY;
 
547
        if (unlikely(au_opt_test(au_mntflags(dentry->d_sb), SHWH)))
 
548
                au_fset_testempty(arg.flags, SHWH);
 
549
        btail = au_dbtaildir(dentry);
 
550
        for (bindex = au_dbstart(dentry); !err && bindex <= btail; bindex++) {
 
551
                struct dentry *h_dentry;
 
552
                h_dentry = au_h_dptr(dentry, bindex);
 
553
                if (h_dentry && h_dentry->d_inode) {
 
554
                        AuDebugOn(!S_ISDIR(h_dentry->d_inode->i_mode));
 
555
                        arg.bindex = bindex;
 
556
                        err = sio_test_empty(dentry, &arg);
 
557
                }
 
558
        }
 
559
 
 
560
        AuTraceErr(err);
 
561
        return err;
 
562
}
 
563
 
 
564
/* ---------------------------------------------------------------------- */
 
565
 
 
566
struct file_operations aufs_dir_fop = {
 
567
        .read           = generic_read_dir,
 
568
        .readdir        = aufs_readdir,
 
569
        .open           = aufs_open_dir,
 
570
        .release        = aufs_release_dir,
 
571
        .flush          = aufs_flush,
 
572
        .fsync          = aufs_fsync_dir,
 
573
};