LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Difference between SYS_getdents and SYS_getdents64 (https://www.linuxquestions.org/questions/linux-kernel-70/difference-between-sys_getdents-and-sys_getdents64-4175626992/)

Smurfbot 04-04-2018 06:50 AM

Difference between SYS_getdents and SYS_getdents64
 
Hi, I am trying to make some modifications to some source code for a program which makes a call to getdents system call via the syscall function. The code only supports a call via using the constant SYS_getdents which doesn't seem to be present on a version of armbian I am using. I did a grep for this under ubuntu and it seems that the exact value is defined differently in different header files(__NR_getdents). What is the correct way to include support for 64 and 32 bit platforms? I would like to have the code so it correctly compiles on both armbian 64 bit and regular x86 variants of linux

Thanks in advance,

Keith Hedger 04-04-2018 07:47 AM

You just need to find what arch you are using, from cli
Code:

uname -m
Then use the appropriate call.

Smurfbot 04-04-2018 02:02 PM

Thanks for the reply. I guess a followup question would be how does one determine which define to use in cases when they are both defined? For example the x86 headers seem to have them defined to different constants and thus different functions in the kernel syscall table. I am actually a bit confused by why arm has only one of these defined yet on 64 bit x86 they are both defined?

Thanks.

Keith Hedger 04-04-2018 02:45 PM

The first place to start is the system manpages.
You then need to decide whether you need the extra info that the getdents64 call supplies, but see this in the manpage:
'These are not the interfaces you are interested in. Look at readdir(3) for the POSIX-conforming C library interface. This page documents the bare kernel system call interfaces.'

Smurfbot 04-05-2018 10:08 AM

Is there some reason then that armbian (64 bit) lacks the SYS_getdents define but has the SYS_getdents64 variant?

Keith Hedger 04-05-2018 11:49 AM

Quote:

Originally Posted by Smurfbot (Post 5839684)
Is there some reason then that armbian (64 bit) lacks the SYS_getdents define but has the SYS_getdents64 variant?

Ask me one on sport! :)


All times are GMT -5. The time now is 03:36 PM.