From: Shailabh Nagar <nagar@watson.ibm.com>
To: maneesh@in.ibm.com
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: Help on automatic population of directories
Date: Mon, 08 Mar 2004 15:38:01 -0500 [thread overview]
Message-ID: <404CD9A9.4020709@watson.ibm.com> (raw)
In-Reply-To: <20040308061401.GA23384@in.ibm.com>
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
prev parent reply other threads:[~2004-03-08 20:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-05 16:55 Help on automatic population of directories Shailabh
2004-03-06 20:51 ` Jan Hudec
2004-03-08 20:32 ` Shailabh Nagar
2004-03-09 8:22 ` Jan Hudec
2004-03-08 6:14 ` Maneesh Soni
2004-03-08 20:38 ` Shailabh Nagar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=404CD9A9.4020709@watson.ibm.com \
--to=nagar@watson.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=maneesh@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).