Solved

Adding syscall to embedded Linux

Posted on 2014-01-27
7
342 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Industry Leaders: 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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

733 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