summaryrefslogtreecommitdiffstats
path: root/fs/autofs/root.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-02-15 02:15:32 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-02-15 02:15:32 +0000
commit86464aed71025541805e7b1515541aee89879e33 (patch)
treee01a457a4912a8553bc65524aa3125d51f29f810 /fs/autofs/root.c
parent88f99939ecc6a95a79614574cb7d95ffccfc3466 (diff)
Merge with Linux 2.2.1.
Diffstat (limited to 'fs/autofs/root.c')
-rw-r--r--fs/autofs/root.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index a3d41fb33..561904318 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -68,13 +68,15 @@ static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldi
{
struct autofs_dir_ent *ent = NULL;
struct autofs_dirhash *dirhash;
+ struct autofs_sb_info *sbi;
struct inode * inode = filp->f_dentry->d_inode;
off_t onr, nr;
if (!inode || !S_ISDIR(inode->i_mode))
return -ENOTDIR;
- dirhash = &((struct autofs_sb_info *)inode->i_sb->u.generic_sbp)->dirhash;
+ sbi = autofs_sbi(inode->i_sb);
+ dirhash = &sbi->dirhash;
nr = filp->f_pos;
switch(nr)
@@ -168,12 +170,10 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
*/
static int autofs_revalidate(struct dentry * dentry)
{
- struct autofs_sb_info *sbi;
struct inode * dir = dentry->d_parent->d_inode;
+ struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
struct autofs_dir_ent *ent;
- sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
-
/* Pending dentry */
if ( dentry->d_flags & DCACHE_AUTOFS_PENDING ) {
if (autofs_oz_mode(sbi))
@@ -220,10 +220,11 @@ static int autofs_root_lookup(struct inode *dir, struct dentry * dentry)
if (!S_ISDIR(dir->i_mode))
return -ENOTDIR;
- sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
+ sbi = autofs_sbi(dir->i_sb);
oz_mode = autofs_oz_mode(sbi);
- DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n", current->pid, current->pgrp, sbi->catatonic, oz_mode));
+ DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n",
+ current->pid, current->pgrp, sbi->catatonic, oz_mode));
/*
* Mark the dentry incomplete, but add it. This is needed so
@@ -266,7 +267,7 @@ static int autofs_root_lookup(struct inode *dir, struct dentry * dentry)
static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
{
- struct autofs_sb_info *sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
+ struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
struct autofs_dirhash *dh = &sbi->dirhash;
struct autofs_dir_ent *ent;
unsigned int n;
@@ -337,7 +338,7 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
*/
static int autofs_root_unlink(struct inode *dir, struct dentry *dentry)
{
- struct autofs_sb_info *sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
+ struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
struct autofs_dirhash *dh = &sbi->dirhash;
struct autofs_dir_ent *ent;
unsigned int n;
@@ -364,7 +365,7 @@ static int autofs_root_unlink(struct inode *dir, struct dentry *dentry)
static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry)
{
- struct autofs_sb_info *sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
+ struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
struct autofs_dirhash *dh = &sbi->dirhash;
struct autofs_dir_ent *ent;
@@ -392,9 +393,10 @@ static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry)
static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
- struct autofs_sb_info *sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
+ struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
struct autofs_dirhash *dh = &sbi->dirhash;
struct autofs_dir_ent *ent;
+ ino_t ino;
if ( !autofs_oz_mode(sbi) )
return -EPERM;
@@ -407,6 +409,7 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
printk("autofs: Out of inode numbers -- what the heck did you do??\n");
return -ENOSPC;
}
+ ino = sbi->next_dir_ino++;
ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
if ( !ent )
@@ -418,15 +421,15 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
return -ENOSPC;
}
- dir->i_nlink++;
- d_instantiate(dentry, iget(dir->i_sb,ent->ino));
-
ent->hash = dentry->d_name.hash;
memcpy(ent->name, dentry->d_name.name, 1+(ent->len = dentry->d_name.len));
- ent->ino = sbi->next_dir_ino++;
+ ent->ino = ino;
ent->dentry = dentry;
autofs_hash_insert(dh,ent);
+ dir->i_nlink++;
+ d_instantiate(dentry, iget(dir->i_sb,ino));
+
return 0;
}
@@ -489,8 +492,7 @@ static inline int autofs_expire_run(struct super_block *sb,
static int autofs_root_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
- struct autofs_sb_info *sbi =
- (struct autofs_sb_info *)inode->i_sb->u.generic_sbp;
+ struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb);
DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,current->pgrp));