Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Syscall from module

Posted on 2001-07-17
8
Medium Priority
?
252 Views
Last Modified: 2008-01-16
Hi

I want to be abe to write to a file from a driver module - loaded into the kernel ....

I tried this
char buffer[6]="sunny";

int fd = sys_open(filename, 1 , 0)
sys_write(fd, buffer, sizeof(buffer));

and nothing happens. "sunny" isnot written to filename

Can somebody plsssss helppppppppp --I am a novice kernel hacker on a deadline
0
Comment
Question by:sunny447492
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6291297
// add
fsync(fd);
close(fd);
0
 

Author Comment

by:sunny447492
ID: 6295816
Nopes it didnt work
0
 
LVL 5

Expert Comment

by:bryanh
ID: 6316030
You don't mention a return code from sys_write(), and the code you show doesn't even get it.

One problem with your code is that the "buffer" argument to sys_write() is an address in the user address space, whereas your buffer is in the kernel address space.  You have to use get_ds() and set_ds() to set the user address space to the kernel address space while sys_write() runs.

Incidentally, people usually go in a layer lower than sys_open/sys_write and call filp_open() and file->f_op->write().  In fact, in my experience the sys_* system call handlers aren't exported for use by loadable kernel modules.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:sunny447492
ID: 6317473
Hi Bryanh,

Thanks for your reply. I had come across an article writtn by Rubini about using get_ds() and set_ds() and I even tried it but was not successful. Would you be able to provide a code snippet thats tested to do such a call -
? I can then give you the points :>

Thanks

Regards,

Sunny
0
 

Author Comment

by:sunny447492
ID: 6317571
Hi Bryanh,

Thanks for your reply. I had come across an article writtn by Rubini about using get_ds() and set_ds() and I even tried it but was not successful. Would you be able to provide a code snippet thats tested to do such a call -
? I can then give you the points :>

Thanks

Regards,

Sunny
0
 
LVL 5

Accepted Solution

by:
bryanh earned 800 total points
ID: 6318081
I've put an example program at ftp://giraffe-data.com/pub/filewrite.c  .  You can contact me at bryanh@giraffe-data.com.  This file is a loadable kernel module -- just compile it and insmod it to see it go.  It works for me.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9871635
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bryanh {http:#6318081}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question