linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Can I allocate few bytes in a file to store info about that file; not visible to user?
@ 2004-04-26 14:32 Vineet Joglekar
  2004-04-26 17:05 ` Glynn Clements
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Joglekar @ 2004-04-26 14:32 UTC (permalink / raw)
  To: linux-c-programming


Hi all,

In ext2fs, while creating a file, can I allocate a number of bytes for that file in advance, such that those bytes are not seen by the user? that is,

suppose I am creating a new file temp, then allocate 50 bytes immediately after creating the file. I want to use those bytes to store the file related info; accessible only to kernel. Whatever data user wants to add, will be added after the these 50 bytes. If user does lseek(fd,0,SEEK_SET), then the file pointer should point to the 51st byte. The 1st 50 bytes shouldnt be visible to user. I dont care if the file size is shown as userdata+50. Is it possible to achieve? If yes, how?

Thanks and regards,

Vineet

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can I allocate few bytes in a file to store info about that file; not visible to user?
  2004-04-26 14:32 Vineet Joglekar
@ 2004-04-26 17:05 ` Glynn Clements
  0 siblings, 0 replies; 4+ messages in thread
From: Glynn Clements @ 2004-04-26 17:05 UTC (permalink / raw)
  To: vintya; +Cc: linux-c-programming


Vineet Joglekar wrote:

> In ext2fs, while creating a file, can I allocate a number of bytes for
> that file in advance, such that those bytes are not seen by the user? 
> that is,
> 
> suppose I am creating a new file temp, then allocate 50 bytes
> immediately after creating the file. I want to use those bytes to
> store the file related info; accessible only to kernel. Whatever data
> user wants to add, will be added after the these 50 bytes. If user
> does lseek(fd,0,SEEK_SET), then the file pointer should point to the
> 51st byte. The 1st 50 bytes shouldnt be visible to user. I dont care
> if the file size is shown as userdata+50. Is it possible to achieve? 
> If yes, how?

Well, you can achieve almost anything if you're willing to spend
enough effort modifying the kernel. But what you are proposing would
be a lot of work; probably much more than you're expecting.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can I allocate few bytes in a file to store info about that file; not visible to user?
@ 2004-04-28 18:15 Vineet Joglekar
  2004-04-29  3:58 ` Vadiraj C S
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Joglekar @ 2004-04-28 18:15 UTC (permalink / raw)
  To: linux-c-programming



>Well, you can achieve almost anything if you're willing to spend >enough effort modifying the kernel. But what you are proposing >would be a lot of work; probably much more than you're expecting.
>--Glynn Clements <glynn.clements@virgin.net>

I was going through the functions like generic_file_write, generic_file_direct_IO, generic_direct_IO and filemap_fdatasync. I was thinking about calling these functions or calling functions written on similar lines to add new few bytes to the file when the inode is created by "ext2_create()". Can any1 please tell me how to do this?

I guess it would have been simpler to call these functions in the call sys_open() when a new file is created, but I want to make changes in kernel code only in ext2 module. playing with sys_open will be like modifying kernel code apart from the ext2 fs module which I dont want.

Thanks and regards,

Vineet

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can I allocate few bytes in a file to store info about that file; not visible to user?
  2004-04-28 18:15 Can I allocate few bytes in a file to store info about that file; not visible to user? Vineet Joglekar
@ 2004-04-29  3:58 ` Vadiraj C S
  0 siblings, 0 replies; 4+ messages in thread
From: Vadiraj C S @ 2004-04-29  3:58 UTC (permalink / raw)
  To: vintya; +Cc: linux-c-programming

> 
> I was going through the functions like generic_file_write, generic_file_direct_IO, generic_direct_IO and filemap_fdatasync. I was thinking about calling these functions or calling functions written on similar lines to add new few bytes to the file when the inode is created by "ext2_create()". Can any1 please tell me how to do this?
> 
> I guess it would have been simpler to call these functions in the call sys_open() when a new file is created, but I want to make changes in kernel code only in ext2 module. playing with sys_open will be like modifying kernel code apart from the ext2 fs module which I dont want.

 If you need the kernel to read your information, you can write your own open() for the module, if you have good hold on filesystem
then this wont be much scary. ext2 filesystem stores all the information in an inode, now you want to write some more at the start
of the datablock.  



-- 

With Best Regards
 Vadiraj C S    

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-04-29  3:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-28 18:15 Can I allocate few bytes in a file to store info about that file; not visible to user? Vineet Joglekar
2004-04-29  3:58 ` Vadiraj C S
  -- strict thread matches above, loose matches on Subject: below --
2004-04-26 14:32 Vineet Joglekar
2004-04-26 17:05 ` Glynn Clements

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).