ProgrammingThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey all. So i'm creating a program for linux using C programming and was wondering if its possible to alter a current system call to receive an argument from a user level program. If so, is there any specific way of doing so?
Thanks all!
Hi.
Could you please provide some example of what you'd like to do.
As I understand, system calls (e.g. open, read, write) is a user-level interface to kernel, so they always recieve an argument from a user-level program. You want to pass some additional arguments? Anyway, to alter a system call you probably should alter kernel code.
I would like to block the open system call until a certain program (that i have created) is run. This open system call is only to be blocked when the user chooses a certain state.
Almost all system calls are issued by (shared) libraries that have been loaded by the applications in question. Usually there are "debug" versions of those libraries, or you can simply roll one of your own.
So.. maybe i should clearly state what my intent is. I am trying to block the open system call whenever it is invoked in order to stop files within a directory from being altered (written to, deleted, moved etc.) before a backup is made.
Therefore for example:
If a user chooses option 1 in the user level program.
Then if someone writes to a file, the open system call has to be invoked.
The open system call is first blocked.
A user level program then creates a backup of that file/directory.
The open system call resumes.
If a user chooses option 2 in the user level program, then the open system call should not be blocked, no backup should be created and the user continues as usual.
> Then if someone writes to a file, the open system call has to be invoked.
Not necessarily, it may have been opened beforehand... If it really is a backup-problem, then perhaps you should remount the whole affected partition read-only before you start the backup.
When a kernel module is loaded, it becomes part of the kernel, so it can do virtually anything: for example can redirect system-calls to itself, and that way it can hide files/processes from any user-land programs, for example.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.