This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / vs_cowbl.h
1 #ifndef _VS_COWBL_H
2 #define _VS_COWBL_H
3
4 #include <linux/fs.h>
5 #include <linux/dcache.h>
6 #include <linux/namei.h>
7
8 extern struct dentry *cow_break_link(const char *pathname);
9
10 static inline int cow_check_and_break(struct nameidata *nd)
11 {
12         struct inode *inode = nd->dentry->d_inode;
13         int error = 0;
14         if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
15                 return -EROFS;
16         if (IS_COW(inode)) {
17                 if (IS_COW_LINK(inode)) {
18                         struct dentry *new_dentry, *old_dentry = nd->dentry;
19                         char *path, *buf;
20
21                         buf = kmalloc(PATH_MAX, GFP_KERNEL);
22                         if (!buf) {
23                                 return -ENOMEM;
24                         }
25                         path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
26                         new_dentry = cow_break_link(path);
27                         kfree(buf);
28                         if (!IS_ERR(new_dentry)) {
29                                 nd->dentry = new_dentry;
30                                 dput(old_dentry);
31                         } else
32                                 error = PTR_ERR(new_dentry);
33                 } else {
34                         inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
35                         inode->i_ctime = CURRENT_TIME;
36                         mark_inode_dirty(inode);
37                 }
38         }
39         return error;
40 }
41
42 #else
43 #warning duplicate inclusion
44 #endif