On Sun, 2006-07-09 at 10:17 -0700, Avinash Ramanath wrote: > Actually I want the option for writing both random bits and zeroes to > the data blocks. > I wanted to know about how I can write them to the data blocks. > I tried the following at the user space: > char *data; > memset(data, 0, 4096); > fprintf(fp, "%s", data); that's not working; you need fwrite not fprintf... also I assume you left out the part where you allocated the buffer space for data > > The program causes a segfault when I am trying to write the zeroed > buffer onto a file. > Could you let me know how I can access the data blocks directly using > inode->i_blocks? I could not find the API which could use this field > for accessing the data blocks. that is because there is no such concept as "the data blocks", that highly depends on the architecture of the filesystem, for example jffs2 is log structured and doesn't even have the concept of "blocks" at all. Many other scenarios exist, and as a result, there is exposure of the low level layout at the higher layers. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/