Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
I have some doubts regarding system calls in Linux. Can anyone kindly tell me: 1) What is the difference between adding a system call to the kernel, and to the ...
  1. #1
    Just Joined!
    Join Date
    Dec 2010
    Posts
    34

    [SOLVED] Regarding adding system calls

    I have some doubts regarding system calls in Linux. Can anyone kindly tell me:

    1) What is the difference between adding a system call to the kernel, and to the library? I am currently porting system calls from NetBSD, and what we are supposed to do is make changes to the .S and .list file, by adding it's entry.

    2) What is the purpose and difference between a .list and .S file?

    3)
    Then why on adding it to library, we only add it's entry to the .S and .list?

    4) Finally, when do we need to export the system calls using ".DEF" file? Is it really required? Some file called, syscall.DEF ( if not mistaken)

    Thanks in advance.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Is this a school project/exercise? In any case, you need to do a lot more reading about Linux kernel programming. Writing system calls is not trivial, and can easily break your system since to do so you need to write loadable kernel modules, or modules that are directly linked to the kernel. Your questions indicate a lack of fundamental understanding, which is why my question about the "school exercise". Forum rules do not allow us to help you with school work except in the most general way.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Dec 2010
    Posts
    34
    Quote Originally Posted by Rubberman View Post
    Is this a school project/exercise? In any case, you need to do a lot more reading about Linux kernel programming. Writing system calls is not trivial, and can easily break your system since to do so you need to write loadable kernel modules, or modules that are directly linked to the kernel. Your questions indicate a lack of fundamental understanding, which is why my question about the "school exercise". Forum rules do not allow us to help you with school work except in the most general way.
    Rubberman, if i am not mistaken i passed out my grad school some 5 years back, and into the software field ( a developer). Yes, i admit i was not into systems side, and was into app dev for the last 4 years.

    And i think, you haven't read my query. I was trying to port system calls and adding it's support to our library. If you know the answer, it's good to guide others, and if you don't know, it's better to keep shut rather than discouraging others and hiding one's own knowledge gap.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Ok. So, since you are so knowledgeable, informed, and well educated I guess I don't need to address your questions and/or issues... One makes assumptions from the types of questions people ask. In your case, a simple "this is something we need to do at work to accomplish x, y, and z and are having some difficulty in understanding how to map our BSD system calls to Linux, both on the kernel space side and the user space side" would have sufficed. And FWIW, I am a professional software engineer w/ 30+ years experience in all aspects of software development, I am a long-term member of the IEEE, and I am an officer of an IEEE affiliation. I have designed, developed, and delivered commercial software all through my career, including embedded device drivers, real-time implementations of the entire TCP/IP protocol suite from the specifications in the DDN Protocol Handbook, and designed and implemented manufacturing cell control and execution systems used to run the factories of most major corporations. I work as a consulting engineer and still develop device drivers for Linux and Solaris as well as perform software design and implementation work for major (Fortune 100) companies. They seem to be willing to pay me $200-250 USD / hour for these skills. You?

    So, let's stop sniping at each other. You need to be more specific about what you are doing, other than just "we are porting system calls to Linux from NetBSD".

    Finally, as you might have determined by the help I have posted on these forums over the past couple of years, I am anything but "discouraging" to people who post questions here. You post one thread, and don't like my response. What does that say about you? I have established friendships with a number of the people who post to these boards because I have been willing to go out of my way to help them solve their various issues and questions, without consideration for the "noobyness" of their questions, or depth of their knowledge. So, even considering your attitude, I am still willing to help you resolve your issues.

    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    kingsmasher1:

    Your post did sound like a homework assignment, so Rubberman was just checking. Please do not be so hostile in your responses. Now that we have clarified the situation, we can try to assist you.

    Now then, I am a bit confused about what you are trying to accomplish. You say that you are "porting system calls". What exactly does this mean, and why do you need to do this?

    It may be a great deal easier to simply write a standard userspace library that emulates the system calls that you need instead of actually modifying the Linux kernel. More details would help us a lot.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Just Joined!
    Join Date
    Dec 2010
    Posts
    34
    Quote Originally Posted by Rubberman View Post
    Ok. So, since you are so knowledgeable, informed, and well educated I guess I don't need to address your questions and/or issues... One makes assumptions from the types of questions people ask. In your case, a simple "this is something we need to do at work to accomplish x, y, and z and are having some difficulty in understanding how to map our BSD system calls to Linux, both on the kernel space side and the user space side" would have sufficed. And FWIW, I am a professional software engineer w/ 30+ years experience in all aspects of software development, I am a long-term member of the IEEE, and I am an officer of an IEEE affiliation. I have designed, developed, and delivered commercial software all through my career, including embedded device drivers, real-time implementations of the entire TCP/IP protocol suite from the specifications in the DDN Protocol Handbook, and designed and implemented manufacturing cell control and execution systems used to run the factories of most major corporations. I work as a consulting engineer and still develop device drivers for Linux and Solaris as well as perform software design and implementation work for major (Fortune 100) companies. They seem to be willing to pay me $200-250 USD / hour for these skills. You?

    So, let's stop sniping at each other. You need to be more specific about what you are doing, other than just "we are porting system calls to Linux from NetBSD".

    Finally, as you might have determined by the help I have posted on these forums over the past couple of years, I am anything but "discouraging" to people who post questions here. You post one thread, and don't like my response. What does that say about you? I have established friendships with a number of the people who post to these boards because I have been willing to go out of my way to help them solve their various issues and questions, without consideration for the "noobyness" of their questions, or depth of their knowledge. So, even considering your attitude, I am still willing to help you resolve your issues.

    Thanks Rubberman, it's really great to know about you. Salute you for your accomplishments. I understand, the forum is not a place for all this, but since you asked about me, so let me tell you. Next time, i will edit my profile to add it.

    Well, for NDA agreements signed by me, i can't disclose things openly, but still a subtle hint should make you understand well about me, and my career.

    Well, in my past 4.5 years IT career i have worked for some of the world's major IT product giants as a direct full-time employee (Software Engineer). One of them being the Schaumburg, Illinois based major Telecom giant for a 2 years, next i worked with the Finland based networking giant in their R&D division as a Linux app programmer/developer.

    Currently, i am with the world's one of the biggest electronic giant, and the name of the company i guess even a 4 years old kid will know, since our products reaches each and every home. But here i am into systems side (a bit different domain than my last 3 companies, so have to gear up my skills a bit, and for that will require help from top guns like you)

    Apart from that, in my academics, throughout i was a topper in my grad school, and got a job at the third year itself in campus recruitment.

    I understand your accomplishments are gigantic, and incomparable to that of mine, but my small achievements that i made in in this short span of 4.5 years i am really satisfied with, and i can bet, there will be hardly any people (few) who could have got the same as me, in such a short span.

    Again at the end, i understand the forum is not a place for my personal bio-data, but i am just replying to your query as you asked about me.

    At the end, thanks for your helping nature, as you indicated at the end that you are still willing to help me.

    My motive is to learn, and be better. Nothing else. For that, there is no other better people than people like you who can really help me.

  7. #7
    Just Joined!
    Join Date
    Dec 2010
    Posts
    34
    Quote Originally Posted by Cabhan View Post
    kingsmasher1:

    Your post did sound like a homework assignment, so Rubberman was just checking. Please do not be so hostile in your responses. Now that we have clarified the situation, we can try to assist you.

    Now then, I am a bit confused about what you are trying to accomplish. You say that you are "porting system calls". What exactly does this mean, and why do you need to do this?

    It may be a great deal easier to simply write a standard userspace library that emulates the system calls that you need instead of actually modifying the Linux kernel. More details would help us a lot.
    Cabhan, we develop a Linux (CE Linux - for ARM) which strictly follows the NetBSD Standards, we have our own library which has some system call APIs, but there is a gap on the number of system calls we support (gap between glibc and our library), so we were adding the support of these system calls by adding their entry in the so called files called syscalls.list, and some .S files and also some headers like unistd.h.

    You know the kernel already have the support of those system calls, and for the programs running in user space to invoke those it should be done via the library, so we were adding it's entry. That's all.

    I hope now you can help me, please let me know if you need further clarifications.

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by kingsmasher1 View Post
    Cabhan, we develop a Linux (CE Linux - for ARM) which strictly follows the NetBSD Standards, we have our own library which has some system call APIs, but there is a gap on the number of system calls we support (gap between glibc and our library), so we were adding the support of these system calls by adding their entry in the so called files called syscalls.list, and some .S files and also some headers like unistd.h.

    You know the kernel already have the support of those system calls, and for the programs running in user space to invoke those it should be done via the library, so we were adding it's entry. That's all.

    I hope now you can help me, please let me know if you need further clarifications.
    That helps clarify some things. Can you specify some of the calls you are trying to add to your userspace libraries? Also, it's been a lonnng time since I had to futz with .S file for this sort of thing, so I am refreshing my memory (my last two gray cells are working overtime these days) on what you need to do in that regard. I'll try to respond to you in a day or so. Perhaps someone else will help clarify what you need to do in the interim.

    Have a great New Year. It seems (if you are still in the Silicon Prairie) that we may be neighbors.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #9
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Ok. From this:
    Each system call has a function number defined in <syscall.h> or <unistd.h>. Internally, system call is invoked by software interrupt 0x80 to transfer control to the kernel. System call table is defined in Linux kernel source file “arch/*/kernel/entry.S ”.
    So, the call ID (numbers) are found in the kernel source include/asm-*/unistd.h and the entry.S file in the kernel source arch/*/kernel/entry.S file. For example, my kernel source for my CentOS 5.5 system is in ~/Development/Linux/Kernels/CentOS/rpmbuild/BUILD/kernel-2.6.18/linux-2.6.18.x86_64. Call that KDir. So, the unistd.h file is in KDir/include/asm-x86_64 and the entry.S file is at KDir/arch/x86_64/kernel/entry.S.

    If this helps, I'll get back to you on the user-space side of things. Also, here are a couple of helpful links:

    Implementing a System Call on Linux 2.6 for i386
    Kernel command using Linux system calls
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  10. #10
    Just Joined!
    Join Date
    Dec 2010
    Posts
    34
    Quote Originally Posted by Rubberman View Post
    Ok. From this:

    So, the call ID (numbers) are found in the kernel source include/asm-*/unistd.h and the entry.S file in the kernel source arch/*/kernel/entry.S file. For example, my kernel source for my CentOS 5.5 system is in ~/Development/Linux/Kernels/CentOS/rpmbuild/BUILD/kernel-2.6.18/linux-2.6.18.x86_64. Call that KDir. So, the unistd.h file is in KDir/include/asm-x86_64 and the entry.S file is at KDir/arch/x86_64/kernel/entry.S.

    If this helps, I'll get back to you on the user-space side of things. Also, here are a couple of helpful links:

    Hi Rubberman, am back again.
    We have a file called mylib_syscalls.list, under mylib/src/lib/libc/arch/arm/sys:

    So we have to add some system calls as under, by below instructions (instructions, someone else has investigated and put, before myself joining the team, and he has left).

    mylib_syscalls.list has below format:
    # Syscall name # args type weak strong

    access 3 R -

    chdir 1 R -

    chmod 2 R -

    chown32 3 P - chown

    close 1 S close slibc_close

    dup 1 R -

    dup2 2 R -

    epoll_create 1 R -

    epoll_ctl 4 R -

    epoll_wait 4 R -

    fchdir 1 R -

    fchmod 2 R -

    futex 4 R -

    ftruncate 2 R -

    fork 0 W slibc_fork

    getitimer 2 R -

    getpid 1 R -

    getpgrp 0 R -

    getppid 1 R -

    gettid 1 R -

    getrusage 2 R -

    gettimeofday 2 R -

    getegid32 0 P - getegid

    geteuid32 0 P - geteuid

    getgid32 0 P - getgid

    ugetrlimit 2 P - getrlimit

    getuid32 0 P - getuid

    ioctl 3 W slibc_ioctl

    kill 2 R -

    link 2 R -

    lseek 3 S lseek slibc_lseek

    madvise 3 R -

    As a first step, can you kindly help me what are these "R", "W", "S" etc. How to know wether any system call falls in which category? Also what is the strong there for?

    For example: few of the guidelines of the system calls to be implemented are given below:
    2
    create_module
    No
    No
    1.This system call needs to implemented in mylibc for (x86,mips & ppc), by adding in mylibc_syscalls.list
    2. For ARM this systemcall is not present in unistd.h, this returns ENOSYS
    Needs to be implemented
    MEDIUM
    10

    3
    epoll_create
    No
    No
    1. This system call needs to be implemented for All archs by adding in myibc_sysalls.list file.
    2. Add the prototype in sys/epoll.h
    Needs to be implemented
    MEDIUM
    5

    4
    epoll_ctl
    No
    No
    1. This system call needs to be implemented for All archs by adding in slibc_sysalls.list file.
    2. Add the prototype in sys/epoll.h
    Needs to be implemented
    MEDIUM
    5

    5
    epoll_wait
    No
    No
    1. This system call needs to be implemented for All archs by adding in slibc_sysalls.list file.
    2. Add the prototype in sys/epoll.h
    Needs to be implemented
    MEDIUM
    5

    6
    fchmodat
    No
    No
    1. This system call needs to be implemented for All archs by adding in slibc_sysalls.list file.
    2. Add the prototype in sys/stat.h.
    Needs to be implemented
    MEDIUM
    5

    7
    fstatfs
    Yes
    Yes
    This system call is already implemented in sslibc, need to be exported in libc.def
    Needs to be exported
    LOW
    1

    8
    futimesat
    No
    No
    1.This system call needs to be implemented for All archs by adding in slibc_sysalls.list file.
    2. Add the prototype in include/fcntl.h file
    Needs to be implemented
    MEDIUM
    5

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...