From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shailabh Nagar Subject: Re: Help on automatic population of directories Date: Mon, 08 Mar 2004 15:38:01 -0500 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <404CD9A9.4020709@watson.ibm.com> References: <4048B0ED.1010702@watson.ibm.com> <20040308061401.GA23384@in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-fsdevel Return-path: Received: from e6.ny.us.ibm.com ([32.97.182.106]:62342 "EHLO e6.ny.us.ibm.com") by vger.kernel.org with ESMTP id S261204AbUCHUiI (ORCPT ); Mon, 8 Mar 2004 15:38:08 -0500 Received: from northrelay04.pok.ibm.com (northrelay04.pok.ibm.com [9.56.224.206]) by e6.ny.us.ibm.com (8.12.10/8.12.2) with ESMTP id i28Kc74i676412 for ; Mon, 8 Mar 2004 15:38:07 -0500 To: maneesh@in.ibm.com In-Reply-To: <20040308061401.GA23384@in.ibm.com> List-Id: linux-fsdevel.vger.kernel.org Maneesh Soni wrote: >For creating new files, dentry and inode for the new files are needed. So >that can be done as follows where dentry is the dentry for the directory >under which you want to create new files. > > down(&dentry->d_inode->i_sem); > new_dentry = rcfs_get_dentry(dentry->d_inode, "New_file"); > if (!IS_ERR(new_dentry)) { > retval = rcfs_mknod(dentry->d_inode, new_dentry, mode, 0); > } > up(&dentry->d_inode->i_sem); > >Now for rcfs_get_dentry(), have a look at sysfs_get_dentry(). This should >allocate new dentry if it is not already in dcache. Also you have to >define ->lookup() dir_inode operation as simple_lookup(). > > > Thanks for that simple code snippet which works well (with the mode value set properly). This is exactly what I was looking for ! Now onto autodelete..... >>Q2: How can one find the vfsmnt given the dentry of a directory that has >>just been created ? >> >>I was thinking of using d_path() to lookup the complete path of the >>just-created directory and then calling a modified version of sys_mknod >>on the resulting string. Probably not the best way of doing this but it >>was simpler to understand :-) But I'm having trouble determining the >>vfsmnt from the dentry returned from rcfs_mknod - I tried using >>current->namespace->root and also current->fs->rootmnt with no success - >>dpath returns blank or garbage as the resulting string and not >>"/rcfs/hello/" which is what I expect when directory hello is being created. >> >> >> > >Why do you need this?.. It seems you want to know the absolute path for the >new created dentry. > > Yes, I was thinking of getting the absolute path and then using a modified sys_mknod (without the copy/from user for the pathname) to create the entry. Obviously pretty inefficient as Jan Hudec pointed out :-( -- Shailabh