From: Ben O. <ben...@us...> - 2002-02-24 00:19:03
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv1244 Modified Files: dir.c Log Message: Ben: changes to njbfs_get_attr calls intentionally disable proc_rename (wasn't working) add real support for njbfs_create Index: dir.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/dir.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dir.c 15 Feb 2002 20:03:04 -0000 1.4 --- dir.c 24 Feb 2002 00:19:00 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- */ + #include <linux/slab.h> #include <linux/module.h> #include <linux/kernel.h> *************** *** 35,38 **** --- 36,40 ---- #include "njbfs.h" #include "njbfs_proc.h" + #include "njbfs_dir.h" static int njbfs_lookup_validate(struct dentry *, int); *************** *** 216,227 **** struct njbfs_sb_info *info = (struct njbfs_sb_info *) sb->u.generic_sbp; ! struct njbfs_fattr fattr; struct inode *inode; ! int res; ! dbg("dname:%s", dentry->d_name.name); ! if ((res = njbfs_get_attr(dentry, &fattr, ! (struct njbfs_sb_info *) dir->i_sb->u. ! generic_sbp)) < 0) { inode = NULL; dentry->d_op = &njbfs_dentry_operations; --- 218,230 ---- struct njbfs_sb_info *info = (struct njbfs_sb_info *) sb->u.generic_sbp; ! struct njbfs_fattr *fattr; struct inode *inode; ! int res = 0; ! /* ben: I'm not sure where -ERESTARTSYS could be returned ! from, so this is kinda broken... */ ! ! fattr = njbfs_get_attr(dentry, info); ! if (!fattr) { inode = NULL; dentry->d_op = &njbfs_dentry_operations; *************** *** 235,241 **** return NULL; } - fattr.f_ino = iunique(dentry->d_sb, 2); - inode = njbfs_iget(dir->i_sb, &fattr); if (inode) { dentry->d_op = &njbfs_dentry_operations; --- 238,245 ---- return NULL; } + + fattr->f_ino = iunique(dentry->d_sb, 2); + inode = njbfs_iget(dir->i_sb, fattr); if (inode) { dentry->d_op = &njbfs_dentry_operations; *************** *** 250,263 **** struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! struct njbfs_fattr fattr; struct inode *inode; ! ! if (njbfs_get_attr(dentry, &fattr, info) < 0) { info("njbfs_get_attr failed"); return -1; } ! fattr.f_ino = iunique(dentry->d_sb, 2); ! inode = njbfs_iget(dentry->d_sb, &fattr); if (!inode) return -EACCES; --- 254,268 ---- struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! struct njbfs_fattr *fattr; struct inode *inode; ! ! fattr = njbfs_get_attr(dentry, info); ! if ( !fattr ) { info("njbfs_get_attr failed"); return -1; } ! fattr->f_ino = iunique(dentry->d_sb, 2); ! inode = njbfs_iget(dentry->d_sb, fattr); if (!inode) return -EACCES; *************** *** 275,278 **** --- 280,287 ---- int res; + /* ben: can't think of a great use for mkdir now. */ + info("sorry, no making of directories."); + return -EINVAL; + njbfs_get_name(dentry, buf); if ((res = njbfs_proc_mkdir(info, buf)) < 0) { *************** *** 286,302 **** static int njbfs_create(struct inode *dir, struct dentry *dentry, int mode) { struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! char buf[NJBFS_MAXPATHLEN]; int res; ! njbfs_get_name(dentry, buf); ! if ((res = njbfs_proc_create(info, buf)) < 0) { err("create failed"); return res; } ! njbfs_cache_invalidate(dentry->d_parent); ! return njbfs_instantiate(dentry); } --- 295,348 ---- static int njbfs_create(struct inode *dir, struct dentry *dentry, int mode) { + struct inode *inode; + struct njbfs_fattr *fattr; + struct njbfs_dirlist_node *p; struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! static char buf[NJBFS_MAXPATHLEN]; int res; ! strncpy(buf, dentry->d_name.name, dentry->d_name.len); ! buf[dentry->d_name.len] = '\0'; ! ! if ((res = njbfs_proc_create(info, buf, &fattr)) < 0) { err("create failed"); return res; } + SAFE_STRDUP(fattr->fname, buf); ! p = kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); ! if (!p ) { ! err("couldn't kmalloc dirlist_node"); ! return -ENOMEM; ! } ! ! /* give us a dirlist node with the exact requested filename */ ! res = njbfs_get_dirlist_node_from_fattr(p, ! fattr, LOADDIR_EXACTNAME); ! if ( res < 0 ) { ! err("couldn't create dirlist_node!"); ! return res; ! } ! ! /* get the directory name under which we are trying to ! create the file, and add the dirlist_node to ! this directories cache */ ! njbfs_get_dirname(dentry, buf); ! res = njbfs_cache_addnode(info, buf, p); ! if ( res < 0 ) { ! err("couldn't add the created file to the cache"); ! kfree(p); ! return res; ! } ! ! fattr->f_ino = iunique(dentry->d_sb, 2); ! inode = njbfs_iget(dentry->d_sb, fattr); ! if ( !inode ) { ! return -EINVAL; ! } ! ! d_instantiate(dentry, inode); ! return 0; } *************** *** 324,327 **** --- 370,381 ---- (struct njbfs_sb_info *) old_dentry->d_sb->u.generic_sbp; int res; + + /* + ben: this code is still mostly broken... + I don't know if I broke it or what. + I think it might never have worked right. + */ + info("njbfs: sorry, this feature is broken for now."); + return -EINVAL; if (new_dentry->d_inode) { |