[Devel] Re: [PATCH 06/10] Define mknod_ptmx()

Serge E. Hallyn serue at us.ibm.com
Mon Sep 29 06:14:09 PDT 2008


Quoting sukadev at linux.vnet.ibm.com (sukadev at linux.vnet.ibm.com):
> Serge E. Hallyn [serue at us.ibm.com] wrote:
> | > +	/*
> | > +	 * Create a new 'ptmx' node in this mount of devpts.
> | > +	 */
> | > +	inode = new_inode(sb);
> | > +	if (!inode) {
> | > +		printk(KERN_ERR "Unable to alloc inode for ptmx node\n");
> | > +		dput(dentry);
> | > +		return -ENOMEM;
> | > +	}
> | > +
> | > +	inode->i_uid = inode->i_gid = 0;
> | > +	inode->i_blocks = 0;
> | > +	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
> | > +
> | > +	mode = S_IFCHR|opts->ptmxmode;
> | > +	init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
> | > +
> | > +	d_add(dentry, inode);
> | 
> | Actually, you never do dput this dentry.
> 
> kill_litter_super() should dput it right ? Earlier we were not caching
> ptmx_dentry and so relied on kill_litter_super() to dput.
> 
> Now that I have ptmx_dentry cached, I could explicitly dput() in
> devpts_kill_sb() and go back to kill_anon_super(). Would that be better
> ?

I think so, but unless someone backs me up on that, ignore me.

> | At the moment you need to dput it here, then once you cache it, you
> | don't dput it here, but dput the cache one at devpts_kill_sb.  Right?
> | 
> | > +	printk(KERN_DEBUG "Created ptmx node in devpts ino %lu\n",
> | > +			inode->i_ino);
> | > +
> | > +	return 0;
> | > +}
> | > +#endif
> | > +
> | >  static int devpts_remount(struct super_block *sb, int *flags, char *data)
> | >  {
> | >  	struct pts_fs_info *fsi = DEVPTS_SB(sb);
> | > @@ -136,6 +204,9 @@ static int devpts_show_options(struct seq_file *seq, struct vfsmount *vfs)
> | >  	if (opts->setgid)
> | >  		seq_printf(seq, ",gid=%u", opts->gid);
> | >  	seq_printf(seq, ",mode=%03o", opts->mode);
> | > +#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
> | > +	seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode);
> | > +#endif
> | > 
> | >  	return 0;
> | >  }
> | > @@ -156,6 +227,7 @@ static void *new_pts_fs_info(void)
> | > 
> | >  	ida_init(&fsi->allocated_ptys);
> | >  	fsi->mount_opts.mode = DEVPTS_DEFAULT_MODE;
> | > +	fsi->mount_opts.ptmxmode = DEVPTS_DEFAULT_PTMX_MODE;
> | > 
> | >  	return fsi;
> | >  }
> | > @@ -211,7 +283,7 @@ static void devpts_kill_sb(struct super_block *sb)
> | >  	struct pts_fs_info *fsi = DEVPTS_SB(sb);
> | > 
> | >  	kfree(fsi);
> | > -	kill_anon_super(sb);
> | > +	kill_litter_super(sb);
> | >  }
> | > 
> | >  static struct file_system_type devpts_fs_type = {
> | > -- 
> | > 1.5.2.5
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list