patch-1.3.46 linux/fs/namei.c
Next file: linux/fs/open.c
Previous file: linux/fs/msdos/inode.c
Back to the patch index
Back to the overall index
- Lines: 331
- Date:
Mon Dec 11 06:56:36 1995
- Orig file:
v1.3.45/linux/fs/namei.c
- Orig date:
Mon Nov 27 12:48:32 1995
diff -u --recursive --new-file v1.3.45/linux/fs/namei.c linux/fs/namei.c
@@ -136,13 +136,13 @@
return -ETXTBSY;
}
}
- inode->i_wcount++;
+ inode->i_writecount++;
return 0;
}
void put_write_access(struct inode * inode)
{
- inode->i_wcount--;
+ inode->i_writecount--;
}
/*
@@ -151,7 +151,7 @@
* fathers (pseudo-roots, mount-points)
*/
int lookup(struct inode * dir,const char * name, int len,
- struct inode ** result)
+ struct inode ** result)
{
struct super_block * sb;
int perm;
@@ -185,7 +185,7 @@
*result = dir;
return 0;
}
- return dir->i_op->lookup(dir,name,len,result);
+ return dir->i_op->lookup(dir, name, len, result);
}
int follow_link(struct inode * dir, struct inode * inode,
@@ -211,8 +211,8 @@
* dir_namei() returns the inode of the directory of the
* specified name, and the name within that directory.
*/
-static int dir_namei(const char * pathname, int * namelen, const char ** name,
- struct inode * base, struct inode ** res_inode)
+static int dir_namei(const char *pathname, int *namelen, const char **name,
+ struct inode * base, struct inode **res_inode)
{
char c;
const char * thisname;
@@ -237,7 +237,7 @@
if (!c)
break;
base->i_count++;
- error = lookup(base,thisname,len,&inode);
+ error = lookup(base, thisname, len, &inode);
if (error) {
iput(base);
return error;
@@ -257,24 +257,24 @@
}
static int _namei(const char * pathname, struct inode * base,
- int follow_links, struct inode ** res_inode)
+ int follow_links, struct inode ** res_inode)
{
- const char * basename;
+ const char *basename;
int namelen,error;
struct inode * inode;
*res_inode = NULL;
- error = dir_namei(pathname,&namelen,&basename,base,&base);
+ error = dir_namei(pathname, &namelen, &basename, base, &base);
if (error)
return error;
base->i_count++; /* lookup uses up base */
- error = lookup(base,basename,namelen,&inode);
+ error = lookup(base, basename, namelen, &inode);
if (error) {
iput(base);
return error;
}
if (follow_links) {
- error = follow_link(base,inode,0,0,&inode);
+ error = follow_link(base, inode, 0, 0, &inode);
if (error)
return error;
} else
@@ -283,14 +283,14 @@
return 0;
}
-int lnamei(const char * pathname, struct inode ** res_inode)
+int lnamei(const char *pathname, struct inode **res_inode)
{
int error;
char * tmp;
- error = getname(pathname,&tmp);
+ error = getname(pathname, &tmp);
if (!error) {
- error = _namei(tmp,NULL,0,res_inode);
+ error = _namei(tmp, NULL, 0, res_inode);
putname(tmp);
}
return error;
@@ -303,14 +303,14 @@
* Open, link etc use their own routines, but this is enough for things
* like 'chmod' etc.
*/
-int namei(const char * pathname, struct inode ** res_inode)
+int namei(const char *pathname, struct inode **res_inode)
{
int error;
char * tmp;
- error = getname(pathname,&tmp);
+ error = getname(pathname, &tmp);
if (!error) {
- error = _namei(tmp,NULL,1,res_inode);
+ error = _namei(tmp, NULL, 1, res_inode);
putname(tmp);
}
return error;
@@ -330,7 +330,7 @@
* for symlinks (where the permissions are checked later).
*/
int open_namei(const char * pathname, int flag, int mode,
- struct inode ** res_inode, struct inode * base)
+ struct inode ** res_inode, struct inode * base)
{
const char * basename;
int namelen,error;
@@ -338,7 +338,7 @@
mode &= S_IALLUGO & ~current->fs->umask;
mode |= S_IFREG;
- error = dir_namei(pathname,&namelen,&basename,base,&dir);
+ error = dir_namei(pathname, &namelen, &basename, base, &dir);
if (error)
return error;
if (!namelen) { /* special case: '/usr/' etc */
@@ -357,7 +357,7 @@
dir->i_count++; /* lookup eats the dir */
if (flag & O_CREAT) {
down(&dir->i_sem);
- error = lookup(dir,basename,namelen,&inode);
+ error = lookup(dir, basename, namelen, &inode);
if (!error) {
if (flag & O_EXCL) {
iput(inode);
@@ -371,14 +371,16 @@
error = -EROFS;
else {
dir->i_count++; /* create eats the dir */
- error = dir->i_op->create(dir,basename,namelen,mode,res_inode);
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
+ error = dir->i_op->create(dir, basename, namelen, mode, res_inode);
up(&dir->i_sem);
iput(dir);
return error;
}
up(&dir->i_sem);
} else
- error = lookup(dir,basename,namelen,&inode);
+ error = lookup(dir, basename, namelen, &inode);
if (error) {
iput(dir);
return error;
@@ -409,7 +411,7 @@
/*
* An append-only file must be opened in append mode for writing
*/
- if (IS_APPEND(inode) && ((flag & 2) && !(flag & O_APPEND))) {
+ if (IS_APPEND(inode) && ((flag & FMODE_WRITE) && !(flag & O_APPEND))) {
iput(inode);
return -EPERM;
}
@@ -420,6 +422,8 @@
iput(inode);
return error;
}
+ if (inode->i_sb->dq_op)
+ inode->i_sb->dq_op->initialize(inode, -1);
newattrs.ia_size = 0;
newattrs.ia_valid = ATTR_SIZE;
if ((error = notify_change(inode, &newattrs))) {
@@ -434,7 +438,10 @@
up(&inode->i_sem);
inode->i_dirt = 1;
put_write_access(inode);
- }
+ } else
+ if (flag & FMODE_WRITE)
+ if (inode->i_sb->dq_op)
+ inode->i_sb->dq_op->initialize(inode, -1);
*res_inode = inode;
return 0;
}
@@ -446,7 +453,7 @@
struct inode * dir;
mode &= ~current->fs->umask;
- error = dir_namei(filename,&namelen,&basename, NULL, &dir);
+ error = dir_namei(filename, &namelen, &basename, NULL, &dir);
if (error)
return error;
if (!namelen) {
@@ -466,6 +473,8 @@
return -EPERM;
}
dir->i_count++;
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
down(&dir->i_sem);
error = dir->i_op->mknod(dir,basename,namelen,mode,dev);
up(&dir->i_sem);
@@ -503,7 +512,7 @@
int namelen, error;
struct inode * dir;
- error = dir_namei(pathname,&namelen,&basename,NULL,&dir);
+ error = dir_namei(pathname, &namelen, &basename, NULL, &dir);
if (error)
return error;
if (!namelen) {
@@ -523,6 +532,8 @@
return -EPERM;
}
dir->i_count++;
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
down(&dir->i_sem);
error = dir->i_op->mkdir(dir, basename, namelen, mode & 0777 & ~current->fs->umask);
up(&dir->i_sem);
@@ -549,7 +560,7 @@
int namelen, error;
struct inode * dir;
- error = dir_namei(name,&namelen,&basename,NULL,&dir);
+ error = dir_namei(name, &namelen, &basename, NULL, &dir);
if (error)
return error;
if (!namelen) {
@@ -575,6 +586,8 @@
iput(dir);
return -EPERM;
}
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
return dir->i_op->rmdir(dir,basename,namelen);
}
@@ -597,7 +610,7 @@
int namelen, error;
struct inode * dir;
- error = dir_namei(name,&namelen,&basename,NULL,&dir);
+ error = dir_namei(name, &namelen, &basename, NULL, &dir);
if (error)
return error;
if (!namelen) {
@@ -623,6 +636,8 @@
iput(dir);
return -EPERM;
}
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
return dir->i_op->unlink(dir,basename,namelen);
}
@@ -645,7 +660,7 @@
const char * basename;
int namelen, error;
- error = dir_namei(newname,&namelen,&basename,NULL,&dir);
+ error = dir_namei(newname, &namelen, &basename, NULL, &dir);
if (error)
return error;
if (!namelen) {
@@ -665,6 +680,8 @@
return -EPERM;
}
dir->i_count++;
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
down(&dir->i_sem);
error = dir->i_op->symlink(dir,basename,namelen,oldname);
up(&dir->i_sem);
@@ -695,7 +712,7 @@
const char * basename;
int namelen, error;
- error = dir_namei(newname,&namelen,&basename,NULL,&dir);
+ error = dir_namei(newname, &namelen, &basename, NULL, &dir);
if (error) {
iput(oldinode);
return error;
@@ -734,6 +751,8 @@
return -EPERM;
}
dir->i_count++;
+ if (dir->i_sb->dq_op)
+ dir->i_sb->dq_op->initialize(dir, -1);
down(&dir->i_sem);
error = dir->i_op->link(oldinode, dir, basename, namelen);
up(&dir->i_sem);
@@ -766,7 +785,7 @@
const char * old_base, * new_base;
int old_len, new_len, error;
- error = dir_namei(oldname,&old_len,&old_base,NULL,&old_dir);
+ error = dir_namei(oldname, &old_len, &old_base, NULL, &old_dir);
if (error)
return error;
if ((error = permission(old_dir,MAY_WRITE | MAY_EXEC)) != 0) {
@@ -779,7 +798,7 @@
iput(old_dir);
return -EPERM;
}
- error = dir_namei(newname,&new_len,&new_base,NULL,&new_dir);
+ error = dir_namei(newname, &new_len, &new_base, NULL, &new_dir);
if (error) {
iput(old_dir);
return error;
@@ -820,6 +839,8 @@
return -EPERM;
}
new_dir->i_count++;
+ if (new_dir->i_sb->dq_op)
+ new_dir->i_sb->dq_op->initialize(new_dir, -1);
down(&new_dir->i_sem);
error = old_dir->i_op->rename(old_dir, old_base, old_len,
new_dir, new_base, new_len);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this