11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/time.h>
15 #include <linux/slab.h>
17 #include <linux/stat.h>
18 #include <linux/errno.h>
19 #include <linux/string.h>
23 #include <asm/uaccess.h>
25 #include <linux/coda.h>
26 #include <linux/coda_psdev.h>
35 static int coda_link(
struct dentry *old_dentry,
struct inode *dir_inode,
42 static int coda_rename(
struct inode *old_inode,
struct dentry *old_dentry,
49 static int coda_dentry_revalidate(
struct dentry *de,
unsigned int flags);
50 static int coda_dentry_delete(
const struct dentry *);
53 static int coda_venus_readdir(
struct file *coda_file,
void *
buf,
57 static int coda_return_EIO(
void)
61 #define CODA_EIO_ERROR ((void *) (coda_return_EIO))
65 .d_revalidate = coda_dentry_revalidate,
66 .d_delete = coda_dentry_delete,
71 .create = coda_create,
72 .lookup = coda_lookup,
74 .unlink = coda_unlink,
75 .symlink = coda_symlink,
79 .rename = coda_rename,
88 .readdir = coda_readdir,
107 coda_i2s(dir), (
int)length, name);
125 if (inode == ERR_PTR(-
ENOENT))
144 if ((mask &
MAY_EXEC) && !execute_ok(inode))
159 static inline void coda_dir_update_mtime(
struct inode *dir)
161 #ifdef REQUERY_VENUS_FOR_MTIME
178 static inline void coda_dir_inc_nlink(
struct inode *dir)
184 static inline void coda_dir_drop_nlink(
struct inode *dir)
194 const char *name=de->
d_name.name;
195 int length=de->
d_name.len;
204 0, mode, &newfid, &attrs);
210 error = PTR_ERR(inode);
215 coda_dir_update_mtime(dir);
223 static int coda_mkdir(
struct inode *dir,
struct dentry *de,
umode_t mode)
227 const char *name = de->
d_name.name;
235 attrs.va_mode =
mode;
237 name, len, &newfid, &attrs);
243 error = PTR_ERR(inode);
248 coda_dir_inc_nlink(dir);
249 coda_dir_update_mtime(dir);
258 static int coda_link(
struct dentry *source_de,
struct inode *dir_inode,
261 struct inode *inode = source_de->
d_inode;
262 const char * name = de->
d_name.name;
270 coda_i2f(dir_inode), (
const char *)name, len);
276 coda_dir_update_mtime(dir_inode);
284 static int coda_symlink(
struct inode *dir_inode,
struct dentry *de,
287 const char *name = de->
d_name.name;
309 coda_dir_update_mtime(dir_inode);
315 static int coda_unlink(
struct inode *dir,
struct dentry *de)
318 const char *name = de->
d_name.name;
325 coda_dir_update_mtime(dir);
330 static int coda_rmdir(
struct inode *dir,
struct dentry *de)
332 const char *name = de->
d_name.name;
343 coda_dir_drop_nlink(dir);
344 coda_dir_update_mtime(dir);
350 static int coda_rename(
struct inode *old_dir,
struct dentry *old_dentry,
351 struct inode *new_dir,
struct dentry *new_dentry)
353 const char *old_name = old_dentry->
d_name.name;
354 const char *new_name = new_dentry->
d_name.name;
355 int old_length = old_dentry->
d_name.len;
356 int new_length = new_dentry->
d_name.len;
360 coda_i2f(new_dir), old_length, new_length,
361 (
const char *) old_name, (
const char *)new_name);
365 coda_dir_drop_nlink(old_dir);
366 coda_dir_inc_nlink(new_dir);
368 coda_dir_update_mtime(old_dir);
369 coda_dir_update_mtime(new_dir);
372 coda_flag_inode(old_dir,
C_VATTR);
373 coda_flag_inode(new_dir,
C_VATTR);
381 static int coda_readdir(
struct file *coda_file,
void *
buf,
filldir_t filldir)
384 struct file *host_file;
391 if (!host_file->
f_op)
394 if (host_file->
f_op->readdir)
400 struct inode *host_inode = host_file->
f_path.dentry->d_inode;
407 ret = host_file->
f_op->readdir(host_file, buf, filldir);
408 file_accessed(host_file);
415 ret = coda_venus_readdir(coda_file, buf, filldir);
420 static inline unsigned int CDT2DT(
unsigned char cdt)
440 static int coda_venus_readdir(
struct file *coda_file,
void *buf,
446 struct file *host_file;
459 de = coda_file->
f_path.dentry;
463 if (!vdir)
return -
ENOMEM;
465 if (coda_file->
f_pos == 0) {
472 if (coda_file->
f_pos == 1) {
491 if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) {
509 if (name.name[0] ==
'.' && (name.len == 1 ||
510 (vdir->
d_name[1] ==
'.' && name.len == 2)))
522 type = CDT2DT(vdir->
d_type);
523 ret = filldir(buf, name.name, name.len,
524 coda_file->
f_pos, ino, type);
535 return result ? result :
ret;
539 static int coda_dentry_revalidate(
struct dentry *de,
unsigned int flags)
570 spin_unlock(&cii->
c_lock);
581 static int coda_dentry_delete(
const struct dentry *
dentry)
609 struct inode *inode = dentry->
d_inode;
626 old_ino = inode->
i_ino;
630 printk(
"Coda: inode %ld, fid %s changed type!\n",
636 if (inode->
i_ino != old_ino)
643 spin_unlock(&cii->
c_lock);