UBUNTU: ubuntu: AUFS -- update to 806051bcbeec27748aae2b7957726a4e63ff308e
[linux-flexiantxendom0-natty.git] / ubuntu / aufs / hfsplus.c
1 /*
2  * Copyright (C) 2010-2011 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 <linux/file.h>
30 #include "aufs.h"
31
32 struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex)
33 {
34         struct file *h_file;
35         struct dentry *h_dentry;
36
37         h_dentry = au_h_dptr(dentry, bindex);
38         AuDebugOn(!h_dentry);
39         AuDebugOn(!h_dentry->d_inode);
40         IMustLock(h_dentry->d_inode);
41
42         h_file = NULL;
43         if (au_test_hfsplus(h_dentry->d_sb)
44             && S_ISREG(h_dentry->d_inode->i_mode))
45                 h_file = au_h_open(dentry, bindex,
46                                    O_RDONLY | O_NOATIME | O_LARGEFILE,
47                                    /*file*/NULL);
48         return h_file;
49 }
50
51 void au_h_open_post(struct dentry *dentry, aufs_bindex_t bindex,
52                     struct file *h_file)
53 {
54         if (h_file) {
55                 fput(h_file);
56                 au_sbr_put(dentry->d_sb, bindex);
57         }
58 }