11 #include <linux/errno.h>
13 #include <linux/slab.h>
14 #include <linux/random.h>
19 static inline void hfsplus_instantiate(
struct dentry *
dentry,
22 dentry->
d_fsdata = (
void *)(
unsigned long)cnid;
27 static struct dentry *hfsplus_lookup(
struct inode *dir,
struct dentry *dentry,
30 struct inode *inode =
NULL;
33 hfsplus_cat_entry
entry;
63 dentry->
d_fsdata = (
void *)(
unsigned long)cnid;
70 if (entry.file.user_info.fdType ==
72 entry.file.user_info.fdCreator ==
74 (entry.file.create_date ==
75 HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->
77 entry.file.create_date ==
78 HFSPLUS_I(sb->
s_root->d_inode)->
80 HFSPLUS_SB(sb)->hidden_dir) {
92 dentry->
d_fsdata = (
void *)(
unsigned long)cnid;
98 HFSPLUS_SB(sb)->hidden_dir->i_ino,
103 dentry->
d_fsdata = (
void *)(
unsigned long)cnid;
112 return ERR_CAST(inode);
114 HFSPLUS_I(inode)->linkid = linkid;
116 d_add(dentry, inode);
125 struct inode *inode = filp->
f_path.dentry->d_inode;
129 hfsplus_cat_entry
entry;
148 if (filldir(dirent,
".", 1, 0, inode->
i_ino,
DT_DIR))
153 if (
fd.entrylength >
sizeof(entry) ||
fd.entrylength < 0) {
170 if (filldir(dirent,
"..", 2, 1,
190 if (
fd.entrylength >
sizeof(entry) ||
fd.entrylength < 0) {
209 if (HFSPLUS_SB(sb)->hidden_dir &&
210 HFSPLUS_SB(sb)->hidden_dir->i_ino ==
213 if (filldir(dirent, strbuf, len, filp->
f_pos,
222 if (filldir(dirent, strbuf, len, filp->
f_pos,
247 list_add(&rd->
list, &HFSPLUS_I(inode)->open_dir_list);
255 static int hfsplus_dir_release(
struct inode *inode,
struct file *
file)
267 static int hfsplus_link(
struct dentry *src_dentry,
struct inode *dst_dir,
268 struct dentry *dst_dentry)
271 struct inode *inode = src_dentry->
d_inode;
272 struct inode *src_dir = src_dentry->
d_parent->d_inode;
291 src_dir, &src_dentry->
d_name,
298 HFSPLUS_I(inode)->linkid =
id;
300 src_dentry->
d_fsdata = (
void *)(
unsigned long)cnid;
302 &src_dentry->
d_name, inode);
314 hfsplus_instantiate(dst_dentry, inode, cnid);
317 mark_inode_dirty(inode);
325 static int hfsplus_unlink(
struct inode *dir,
struct dentry *dentry)
328 struct inode *inode = dentry->
d_inode;
339 if (inode->
i_ino == cnid &&
358 if (inode->
i_ino == cnid)
361 if (inode->
i_ino != cnid) {
376 mark_inode_dirty(inode);
382 static int hfsplus_rmdir(
struct inode *dir,
struct dentry *dentry)
385 struct inode *inode = dentry->
d_inode;
398 mark_inode_dirty(inode);
404 static int hfsplus_symlink(
struct inode *dir,
struct dentry *dentry,
424 hfsplus_instantiate(dentry, inode, inode->
i_ino);
425 mark_inode_dirty(inode);
437 static int hfsplus_mknod(
struct inode *dir,
struct dentry *dentry,
460 hfsplus_instantiate(dentry, inode, inode->
i_ino);
461 mark_inode_dirty(inode);
467 static int hfsplus_create(
struct inode *dir,
struct dentry *dentry,
umode_t mode,
470 return hfsplus_mknod(dir, dentry, mode, 0);
473 static int hfsplus_mkdir(
struct inode *dir,
struct dentry *dentry,
umode_t mode)
475 return hfsplus_mknod(dir, dentry, mode |
S_IFDIR, 0);
478 static int hfsplus_rename(
struct inode *old_dir,
struct dentry *old_dentry,
479 struct inode *new_dir,
struct dentry *new_dentry)
486 res = hfsplus_rmdir(new_dir, new_dentry);
488 res = hfsplus_unlink(new_dir, new_dentry);
494 old_dir, &old_dentry->
d_name,
495 new_dir, &new_dentry->
d_name);
502 .lookup = hfsplus_lookup,
503 .create = hfsplus_create,
504 .link = hfsplus_link,
505 .unlink = hfsplus_unlink,
506 .mkdir = hfsplus_mkdir,
507 .rmdir = hfsplus_rmdir,
508 .symlink = hfsplus_symlink,
509 .mknod = hfsplus_mknod,
510 .rename = hfsplus_rename,
516 .readdir = hfsplus_readdir,
519 .release = hfsplus_dir_release,