Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / fs / aufs / hfsplus.c
1 /*
2  * Copyright (C) 2010-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  * special support for filesystems which aqucires an inode mutex
21  * at final closing a file, eg, hfsplus.
22  *
23  * This trick is very simple and stupid, just to open the file before really
24  * neceeary open to tell hfsplus that this is not the final closing.
25  * The caller should call au_h_open_pre() after acquiring the inode mutex,
26  * and au_h_open_post() after releasing it.
27  */
28
29 #include "aufs.h"
30
31 struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex)
32 {
33         struct file *h_file;
34         struct dentry *h_dentry;
35
36         h_dentry = au_h_dptr(dentry, bindex);
37         AuDebugOn(!h_dentry);
38         AuDebugOn(!h_dentry->d_inode);
39
40         h_file = NULL;
41         if (au_test_hfsplus(h_dentry->d_sb)
42             && S_ISREG(h_dentry->d_inode->i_mode))
43                 h_file = au_h_open(dentry, bindex,
44                                    O_RDONLY | O_NOATIME | O_LARGEFILE,
45                                    /*file*/NULL);
46         return h_file;
47 }
48
49 void au_h_open_post(struct dentry *dentry, aufs_bindex_t bindex,
50                     struct file *h_file)
51 {
52         if (h_file) {
53                 fput(h_file);
54                 au_sbr_put(dentry->d_sb, bindex);
55         }
56 }