Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / fs / aufs / poll.c
1 /*
2  * Copyright (C) 2005-2013 Junjiro R. 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  * poll operation
21  * There is only one filesystem which implements ->poll operation, currently.
22  */
23
24 #include "aufs.h"
25
26 unsigned int aufs_poll(struct file *file, poll_table *wait)
27 {
28         unsigned int mask;
29         int err;
30         struct file *h_file;
31         struct dentry *dentry;
32         struct super_block *sb;
33
34         /* We should pretend an error happened. */
35         mask = POLLERR /* | POLLIN | POLLOUT */;
36         dentry = file->f_dentry;
37         sb = dentry->d_sb;
38         si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
39         err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/0);
40         if (unlikely(err))
41                 goto out;
42
43         /* it is not an error if h_file has no operation */
44         mask = DEFAULT_POLLMASK;
45         h_file = au_hf_top(file);
46         if (h_file->f_op && h_file->f_op->poll)
47                 mask = h_file->f_op->poll(h_file, wait);
48
49         di_read_unlock(dentry, AuLock_IR);
50         fi_read_unlock(file);
51
52 out:
53         si_read_unlock(sb);
54         AuTraceErr((int)mask);
55         return mask;
56 }