I've been trying to implement a file system using vfs and I've got mkdir and touch working but I can't seem to get echo blah > new file to create a new file with content blah. I tried to use printk to see what gets called during the creation process but it doesn't seem that write is getting called for my file, just open. When I ran strace I see a write call but it is to stdout and not to my file. Any tips on how to go about implementing the behavior I'm after? I've been following the following tutorial with the changes necessary to work on kernel 3.10.34 http://lwn.net/Articles/57369/ . Any help is appreciated, thanks! -- Adam Fowler<ajf2177@columbia.edu>
On Tue, 29 Apr 2014 23:44:51 -0400, Adam Fowler said:
called for my file, just open. When I ran strace I see a write call but it is to stdout and not to my file.
Are you write()'ing to the correct file descriptor number? What is the source code for your userspace, near the open/write/close?
On Wed, Apr 30, 2014 at 9:14 AM, Adam Fowler <ajf2177@columbia.edu> wrote:
I've been trying to implement a file system using vfs and I've got mkdir and touch working but I can't seem to get echo blah > new file to create a new
Can you see if you are able to get the user space buffer and print it? Would be better if you can post some of your code.
file with content blah. I tried to use printk to see what gets called during the creation process but it doesn't seem that write is getting called for my file, just open. When I ran strace I see a write call but it is to stdout and not to my file. Any tips on how to go about implementing the behavior I'm after? I've been following the following tutorial with the changes necessary to work on kernel 3.10.34 http://lwn.net/Articles/57369/ . Any help is appreciated, thanks!
In case you have saved the user space contents and not set the inode->i_size properly try to set that appropriately. But again it would be better to have some code to look at.
--
Adam Fowler<ajf2177@columbia.edu>
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- ---P.K.S
2014-04-30 9:14 GMT+05:30 Adam Fowler <ajf2177@columbia.edu>:
I've been trying to implement a file system using vfs and I've got mkdir and touch working but I can't seem to get echo blah > new file to create a new file with content blah.
touch and mkdir are only for file creation. You need to extend and implement the .write call from struct file_operations, for write support. See: https://github.com/psankar/simplefs/blob/master/simple.c (search for simplefs_write) Sankar
participants (4)
-
Adam Fowler -
Pranay Srivastava -
Sankar P -
Valdis.Kletnieks@vt.edu