X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fcoda%2Fdir.c;h=0c6f7f3b3dd7c36d9ba646b08cac3dc02cbae81f;hb=7d8b6f8e7158f0f307fb8315de1fb962f0c717d9;hp=2fe494a3d0b3bee17a95b3672990a6a69ec2ada6;hpb=daddc0d38b3571bed170afa273a49a0eba090c1e;p=linux-2.6.git diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 2fe494a3d..0c6f7f3b3 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -27,9 +27,10 @@ #include #include +#include "coda_int.h" + /* dir inode-ops */ static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd); -static int coda_mknod(struct inode *dir, struct dentry *new, int mode, dev_t rdev); static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd); static int coda_link(struct dentry *old_dentry, struct inode *dir_inode, struct dentry *entry); @@ -51,11 +52,15 @@ static int coda_dentry_delete(struct dentry *); /* support routines */ static int coda_venus_readdir(struct file *filp, filldir_t filldir, void *dirent, struct dentry *dir); -int coda_fsync(struct file *, struct dentry *dentry, int datasync); -int coda_hasmknod; +/* same as fs/bad_inode.c */ +static int coda_return_EIO(void) +{ + return -EIO; +} +#define CODA_EIO_ERROR ((void *) (coda_return_EIO)) -struct dentry_operations coda_dentry_operations = +static struct dentry_operations coda_dentry_operations = { .d_revalidate = coda_dentry_revalidate, .d_delete = coda_dentry_delete, @@ -70,14 +75,14 @@ struct inode_operations coda_dir_inode_operations = .symlink = coda_symlink, .mkdir = coda_mkdir, .rmdir = coda_rmdir, - .mknod = coda_mknod, + .mknod = CODA_EIO_ERROR, .rename = coda_rename, .permission = coda_permission, .getattr = coda_getattr, .setattr = coda_setattr, }; -struct file_operations coda_dir_operations = { +const struct file_operations coda_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = coda_readdir, @@ -183,7 +188,7 @@ static inline void coda_dir_changed(struct inode *dir, int link) /* optimistically we can also act as if our nose bleeds. The * granularity of the mtime is coarse anyways so we might actually be * right most of the time. Note: we only do this for directories. */ - dir->i_mtime = dir->i_ctime = CURRENT_TIME; + dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; #endif if (link) dir->i_nlink += link; @@ -208,7 +213,7 @@ static int coda_create(struct inode *dir, struct dentry *de, int mode, struct na } error = venus_create(dir->i_sb, coda_i2f(dir), name, length, - 0, mode, 0, &newfid, &attrs); + 0, mode, &newfid, &attrs); if ( error ) { unlock_kernel(); @@ -230,52 +235,6 @@ static int coda_create(struct inode *dir, struct dentry *de, int mode, struct na return 0; } -static int coda_mknod(struct inode *dir, struct dentry *de, int mode, dev_t rdev) -{ - int error=0; - const char *name=de->d_name.name; - int length=de->d_name.len; - struct inode *inode; - struct CodaFid newfid; - struct coda_vattr attrs; - - if ( coda_hasmknod == 0 ) - return -EIO; - - if (!old_valid_dev(rdev)) - return -EINVAL; - - lock_kernel(); - coda_vfs_stat.create++; - - if (coda_isroot(dir) && coda_iscontrol(name, length)) { - unlock_kernel(); - return -EPERM; - } - - error = venus_create(dir->i_sb, coda_i2f(dir), name, length, - 0, mode, rdev, &newfid, &attrs); - - if ( error ) { - unlock_kernel(); - d_drop(de); - return error; - } - - inode = coda_iget(dir->i_sb, &newfid, &attrs); - if ( IS_ERR(inode) ) { - unlock_kernel(); - d_drop(de); - return PTR_ERR(inode); - } - - /* invalidate the directory cnode's attributes */ - coda_dir_changed(dir, 0); - unlock_kernel(); - d_instantiate(de, inode); - return 0; -} - static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) { struct inode *inode; @@ -345,7 +304,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode, coda_dir_changed(dir_inode, 0); atomic_inc(&inode->i_count); d_instantiate(de, inode); - inode->i_nlink++; + inc_nlink(inode); out: unlock_kernel(); @@ -408,7 +367,7 @@ int coda_unlink(struct inode *dir, struct dentry *de) } coda_dir_changed(dir, 0); - de->d_inode->i_nlink--; + drop_nlink(de->d_inode); unlock_kernel(); return 0; @@ -435,7 +394,7 @@ int coda_rmdir(struct inode *dir, struct dentry *de) } coda_dir_changed(dir, -1); - de->d_inode->i_nlink--; + drop_nlink(de->d_inode); d_delete(de); unlock_kernel(); @@ -482,7 +441,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry, /* file operations for directories */ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir) { - struct dentry *coda_dentry = coda_file->f_dentry; + struct dentry *coda_dentry = coda_file->f_path.dentry; struct coda_file_info *cfi; struct file *host_file; struct inode *host_inode; @@ -494,8 +453,8 @@ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir) coda_vfs_stat.readdir++; - host_inode = host_file->f_dentry->d_inode; - down(&host_inode->i_sem); + host_inode = host_file->f_path.dentry->d_inode; + mutex_lock(&host_inode->i_mutex); host_file->f_pos = coda_file->f_pos; if (!host_file->f_op->readdir) { @@ -517,7 +476,7 @@ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir) } out: coda_file->f_pos = host_file->f_pos; - up(&host_inode->i_sem); + mutex_unlock(&host_inode->i_mutex); return ret; } @@ -554,7 +513,7 @@ static int coda_venus_readdir(struct file *filp, filldir_t filldir, ino_t ino; int ret, i; - vdir = (struct venus_dirent *)kmalloc(sizeof(*vdir), GFP_KERNEL); + vdir = kmalloc(sizeof(*vdir), GFP_KERNEL); if (!vdir) return -ENOMEM; i = filp->f_pos; @@ -585,14 +544,14 @@ static int coda_venus_readdir(struct file *filp, filldir_t filldir, /* catch truncated reads */ if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) { printk("coda_venus_readdir: short read: %ld\n", - filp->f_dentry->d_inode->i_ino); + filp->f_path.dentry->d_inode->i_ino); ret = -EBADF; break; } /* validate whether the directory file actually makes sense */ if (vdir->d_reclen < vdir_size + vdir->d_namlen) { printk("coda_venus_readdir: Invalid dir: %ld\n", - filp->f_dentry->d_inode->i_ino); + filp->f_path.dentry->d_inode->i_ino); ret = -EBADF; break; }