Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-12-2006, 04:16 AM
|
#1
|
|
Member
Registered: Dec 2005
Posts: 80
Rep:
|
C & kernel data structure & shell script
i want to save the absolute pathname of the file & its md5 hash into one file & while booting the linux kernel want to extract the pathname & its hash value into kernel data structure with same attributes.
So how can i do it?
if i use shell script to insert the contents into the file then how can i extract it into kernel data structure in 'C' program while booting the kernel?
thankx in advance!!!
|
|
|
|
01-12-2006, 10:56 PM
|
#2
|
|
Member
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259
Rep:
|
Hi,
>want to save the absolute pathname of the file & its md5 hash into one file
ok do it by writing a C program that stores the absolute file name and its md5sum
>& while booting the linux kernel want to extract the pathname & its hash value into kernel data structure with same attributes.
so you have to write a system call that writes to data structure that must exist in kernel by modifying kernel and installing it.thus whenever system boots call your user C program that calls that kenrel function which writes to data structure in kernel
>So how can i do it?
write kernel source file that adds system call. exports that function call.use that function to write required attributes in kernel. thats it.
>if i use shell script to insert the contents into the file then how can i extract it into kernel data structure in 'C' program while booting the kernel?
i dont thing you need shell scritps to insert content in file. to extract kenrel data structure write read system call on that data structure.
|
|
|
|
01-13-2006, 06:29 AM
|
#3
|
|
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Rep:
|
Not to be nit picky.. but you should probably write a module that does this and not a system call (which would not be centralized). The reason being if you ever want to upgrade your kernel it is a lot easier to get a module to work with the new kernel then it is to re-patch the kernel with the changes you made for the system call. It is much easier to write something self contained that uses the standard write system call.
|
|
|
|
01-13-2006, 06:57 AM
|
#4
|
|
Member
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259
Rep:
|
jtshaw,
vishalbutte want to maintain kernel data structure as soon as system boots up. so i dont seem any way at userspace to solve this problem with writing a module without using system call that write/read to kernel data structure. i know my solution is difflicult to implement.
|
|
|
|
01-13-2006, 07:34 AM
|
#5
|
|
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Rep:
|
What exactly is calling the system call? System calls by default are user space calls into the kernel, how does that not have the same issue?
It he module is statically compiled into the kernel you can absolutely get the same effect with a better division of code.
|
|
|
|
01-13-2006, 07:52 AM
|
#6
|
|
Member
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259
Rep:
|
hi,
What i consider that to maintain a data structure that have 2 fields filename,its MD5 its needed to add structure header file in kernel then write kernel read/write functions to this structure and export this functions so that user C program can use that thing and by using data_read()/data_write() in user space can map to kernel internal functions by adding new system calls thats it. i did this stuff 2 years back successfully with maintaining big kernel data structure by writing dynamic strings to kenrel memory.
|
|
|
|
01-13-2006, 08:20 AM
|
#7
|
|
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Rep:
|
Pargn,
I'm not saying your method won't work. But the system call part of it can be replaced using a module. The module still gives you all the same access to kernel space structures and prevents you from having to maintain the syscall tables and from having to write a userspace library to call your system calls so that a userspace program can use them.
I've done similar things using both methods and in the long run adding system calls is much harder to maintain... plus you have about a 0% chance of ever getting your code actually into the kernel if you add a system call. All the kernel developers will tell you the same thing, adding system calls is a last resort action and you better have a very very good reason for doing so.
John
|
|
|
|
01-13-2006, 08:38 AM
|
#8
|
|
Member
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259
Rep:
|
yes I agree what you said. even i preferred what i did was last way to acheive what i want to do at that time.i know its hard to implement syscall. but i thought its the only way here.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:19 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|