changing file size at run time in linux kernel code
how to modify the size field of file during their creation and where to do it in kernel code??
|
Do you mean that you want all files to be created with some non-zero size? This would very likely break a lot of programs. Why do you think this is a good idea? I sense that you are trying to use the wrong solution to a problem. Why don't you tell us what you are really trying to accomplish?
--- rod. |
Why do you want to create a file in kernel space? In user space, it is very easy even if non-zero size file.
|
my actual problem is:-
i want to encrypt files during their creation and decrypt files during their read operation using AES algorithm, i have also written code in vfs_write() and vfs_read() for encryption and decryption respectively and also it is working nicely, but the only problem now is that k whenever i pass a file to vfs_write() whose length is not multiple of 16 (AES BLOCK SIZE) den AES does padding to it to make it a multiple of 16 and bcz of this the size of the file increases but the write() function does not know about this and so it rejects e.g.:- suppose i enter data as "123", here length is 4 (3 length of data + 1 '\0' character) and so AES padds 12 bytes to it to make it 16 bytes (as AES works on 16 bytes blocks), but write() only takes original length which was 4 and so i want to know how to change the file size to 16 (in this case) and also where to do it in kernel code i tried this inode->i_size=new_length; inode->i_op->truncate(inode); but this is not working bcz kernel hangs and also i am not understanding where to do such things i.e., in which function and how also i tried changing the count variable with new length in vfs_write() but then it gives error as "cat write error: No space left on device" it works fine when i pass file which is a multiple of 16 if anyone know anything about this plz plz help me and if you could suggest me anything it's most welcome....thankyou..... |
You can reference ecryptfs file system's code. It should have reference code.
|
All times are GMT -5. The time now is 08:09 PM. |