Solved

Adding syscall to embedded Linux

Posted on 2014-01-27
7
348 Views
Last Modified: 2014-02-15
I'm trying to a new system call to my embedded system, but for some reason I cannot get it to compile.  The new <sys/my_time.h> is always not found.

Essentially I am trying to create a function that will pass back the number of jiffies from the kernel.  I have looked at several post on google, but they do not help to resolve the compilation issue I am having.

My system:
Linux 2.4-8 using uCLibc-0.9.8.

This system is quite particular, so it may be difficult to provide much assistance.  But I have already performed the following steps.  If there is anything that I am missing, please let me know.

1. Added "sys_my_time" to "call.S" (hosting the syscall table).
2. Added "__NR_my_time 257" to unistd.h.
3. Added function implementation to sys.c. (where "times()" has been implemented)
4. Added "my_time.h" file to uclibc/include/sys" directory. (same as "times.h").
5. Added "my_time.c" file to uclibc/libc/sysdeps/linux/common" directory. (same as "times.c")

Thank you.
0
Comment
Question by:sctccomm
[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
7 Comments
 
LVL 34

Expert Comment

by:sarabande
ID: 39817085
2. Added "__NR_my_time 257" to unistd.h
generally it is a bad idea to changing system headers. for the the unistd.h it is worse cause the header was include by all library functions of all system and subsystem libraries your compiler provides. you would need to rebuild all these libraries to make sure that your new code could work.

also changes to sys.c  would require to rebuild the system libraries and rebuild the kernel. any update of the system in future would spoil all your work.

Sara
0
 
LVL 86

Expert Comment

by:jkr
ID: 39819844
Apart from different opinions, I'd like to assure you that altering kernel sources for your purpose is absolutely on point (wth the described impact, though), that's what they're meant for, sice you are building your very own kernel. What are the problems you are running into?
0
 

Author Comment

by:sctccomm
ID: 39822047
I have a file that is going to use my new system call, my_time().

But when I include the header file, "#include <sys/my_time.h>", I always get a compilation error saying that my_time.h is not found.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 12

Expert Comment

by:stefan73
ID: 39847263
Hmm, this could also be a permission issue. Did you check these?
0
 
LVL 34

Expert Comment

by:sarabande
ID: 39848150
when I include the header file, "#include <sys/my_time.h>", I always get a compilation error
if the compiler says file not found, it is true.  you may look for the following reasons:

- the 'sys' folder is not available at all

try to include <sys/time.h> instead of <sys/my_time.h>. if the time.h was not found either, the compiler does not have access to its own include folders. check the environment variable 'include'. probably you have to reinstall the compiler such that the system headers could be found.

- you have duplicate include folders

if the time.h was found, but not my_time.h, the sys folder was duplicated somehow and the compiler currently accesses the wrong one. you may search your disks and check environment variables 'include' and 'lib' for wrong paths.

Sara
0
 

Accepted Solution

by:
sctccomm earned 0 total points
ID: 39848193
There is not permission issue.

Also, <sys/times.h>, was included originally and so it does recognize the 'sys' directory.

I have discovered that the my <sys/my_times.h> will most likely never get recognized because it is not a standard file that exists in libc.  Thus, in the file in which I would like <sys/my_times.h> to be included get compiled, <sys/my_times.h> will not get recognized.

The only way for this to work would be to call the syscall() directly using the syscall_table ID.
0
 

Author Closing Comment

by:sctccomm
ID: 39861154
There is no good solution for this issue.  Only to force the system call.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Six Sigma Control Plans

726 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