4 * Copyright (c) 1999 Al Smith
6 * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
9 #include <linux/buffer_head.h>
10 #include <linux/string.h>
11 <<<<<<< HEAD
:fs
/efs
/namei
.c
12 #include <linux/efs_fs.h>
14 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/efs
/namei
.c
15 #include <linux/smp_lock.h>
16 #include <linux/exportfs.h>
17 <<<<<<< HEAD
:fs
/efs
/namei
.c
20 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/efs
/namei
.c
23 static efs_ino_t
efs_find_entry(struct inode
*inode
, const char *name
, int len
) {
24 struct buffer_head
*bh
;
28 struct efs_dir
*dirblock
;
29 struct efs_dentry
*dirslot
;
33 if (inode
->i_size
& (EFS_DIRBSIZE
-1))
34 printk(KERN_WARNING
"EFS: WARNING: find_entry(): directory size not a multiple of EFS_DIRBSIZE\n");
36 for(block
= 0; block
< inode
->i_blocks
; block
++) {
38 bh
= sb_bread(inode
->i_sb
, efs_bmap(inode
, block
));
40 printk(KERN_ERR
"EFS: find_entry(): failed to read dir block %d\n", block
);
44 dirblock
= (struct efs_dir
*) bh
->b_data
;
46 if (be16_to_cpu(dirblock
->magic
) != EFS_DIRBLK_MAGIC
) {
47 printk(KERN_ERR
"EFS: find_entry(): invalid directory block\n");
52 for(slot
= 0; slot
< dirblock
->slots
; slot
++) {
53 dirslot
= (struct efs_dentry
*) (((char *) bh
->b_data
) + EFS_SLOTAT(dirblock
, slot
));
55 namelen
= dirslot
->namelen
;
56 nameptr
= dirslot
->name
;
58 if ((namelen
== len
) && (!memcmp(name
, nameptr
, len
))) {
59 inodenum
= be32_to_cpu(dirslot
->inode
);
69 struct dentry
*efs_lookup(struct inode
*dir
, struct dentry
*dentry
, struct nameidata
*nd
) {
71 struct inode
* inode
= NULL
;
74 inodenum
= efs_find_entry(dir
, dentry
->d_name
.name
, dentry
->d_name
.len
);
76 inode
= efs_iget(dir
->i_sb
, inodenum
);
79 return ERR_CAST(inode
);
88 static struct inode
*efs_nfs_get_inode(struct super_block
*sb
, u64 ino
,
94 return ERR_PTR(-ESTALE
);
95 inode
= efs_iget(sb
, ino
);
97 return ERR_CAST(inode
);
99 if (generation
&& inode
->i_generation
!= generation
) {
101 return ERR_PTR(-ESTALE
);
107 struct dentry
*efs_fh_to_dentry(struct super_block
*sb
, struct fid
*fid
,
108 int fh_len
, int fh_type
)
110 return generic_fh_to_dentry(sb
, fid
, fh_len
, fh_type
,
114 struct dentry
*efs_fh_to_parent(struct super_block
*sb
, struct fid
*fid
,
115 int fh_len
, int fh_type
)
117 return generic_fh_to_parent(sb
, fid
, fh_len
, fh_type
,
121 struct dentry
*efs_get_parent(struct dentry
*child
)
123 struct dentry
*parent
;
131 ino
= efs_find_entry(child
->d_inode
, "..", 2);
135 inode
= efs_iget(child
->d_inode
->i_sb
, ino
);
137 error
= PTR_ERR(inode
);
142 parent
= d_alloc_anon(inode
);
153 return ERR_PTR(error
);