Solved

Adding syscall to embedded Linux

Posted on 2014-01-27
7
319 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
7 Comments
 
LVL 33

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 12

Expert Comment

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
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 use strings and some functions related to them in the C programming language.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now