[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: 1738444375153980.jpg (1.09 MB, 2732x1950)
1.09 MB
1.09 MB JPG
i noticed, today, that there are currently 363 x86 syscalls listed in musl libc: https://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/syscall.h.in

i thought that this would make for a really good "syscall of the day" discussion (nevermind the fact that it's already the 9th)
for today, in order to catch us up, as well as maybe foster a bit more discussion and interest, we'll actually start with 7 syscalls. these are:
#define __NR_read                 0
#define __NR_write 1
#define __NR_open 2
#define __NR_close 3
#define __NR_stat 4
#define __NR_fstat 5
#define __NR_lstat 6

luckily for us, these are all pretty similar, so it really works out quite nicely. these are your classic, day one syscalls that pretty much every programmer ought to know about, even if they don't care to delve too deeply into the internals of the system.

ITT, feel free to discuss these syscalls, syscalls in general, file io, and other related topics
my personal suggestion for those who want to get a better understanding of lower level linux but don't know where to start is to just go back to the well, so to speak, and do the classic "Hello, world!" exercise, but compile with
-nostdlib
(or just
-nodefaultlibs
if you want to be lazy). once you've managed to get that done, adding on new syscalls becomes much easier

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
>>
sorry, your thread is off topic. /g/ is for posting kids and AI slop
>>
>>107813965
I'm trying to dive deeper into my knowledge of Linux and Os's in general. What's a good source to learn about Linux's syscalls? Books preferred
>>
>>107814137
i have never read a programming book (in my experience, printed text and code don't mesh super well), but there are a significant number of university (including some of the top in the world) lectures on OSes available for free online
https://www.youtube.com/results?search_query=advanced+operating+systems
i definitely recommend hands-on experimentation over reading or watching things, though. they're honestly not even comparable. you will not learn unless you do. it's really as simple as that
>>
>>107813965
I applaud you for making and interesting and useful thread, sadly it will die, wiped out by slop and bot spam.

In any case, Advanced Programming in the UNIX Environment and The Linux Programming Interface are fascinating and useful reads.

Many times I want to delve deeper into this stuff, but then I remember it has no real use to me and the clock is ticking and I'm running out of time.... But on the other hand, does anything matter? Is one thing more useful than another, to spend time on? None of this nor that is getting me a high paying job or anything anyway.
>>
File: Capture.jpg (73 KB, 619x405)
73 KB
73 KB JPG
>>107813965
Missing a row
>>
>>107813965
the everything is a file abstraction kinda sucks. file reads need a buffer over the block device, streams need a buffer on libc (and duplicated on the kernel for some reason.) block devices exposed as files is even more dumb when it attempts to hack on an abstraction that's just woefully underpowered.
the real abstraction is to be found at the common denominator between all of the implementations they hide. everything is a linear slice of memory.
>>
>>107814852
>and duplicated on the kernel for some reason
i'm getting ahead of myself here, but i imagine you'll be a fan of the __NR_sendfile, __NR_splice, and __NR_copy_file_range days if you dislike unnecessary duplication of resources
>>
>>107813965
cool thread anon
>>
>>107814917
read a little on all of them, they're cool. the insight largely seems to be to work on / rewrite metadata instead.
>>
bumping a bit
>>
>musl
slop
>>
File: file.png (148 KB, 736x966)
148 KB
148 KB PNG
>>107813965
>
__NR_open

You could fill a week with this one alone. Check out O_TMPFILE
>>
>>107813965
lick lick lick pero pero pero
>>
>>107817361
would you really want to lick a programmer girl's toes? do you have any idea where those things have been?
>>
>>107813965
synchronous IO syscalls are a mistake
>>
>>107817686
Yeah, in my mouth.
>>
I have never needed to use syscalls directly in my life.
I'm not proud of it, but I'm not going to need it to keep earning a decent 6-figures salary. Such is life.
>>
>>107817765
I've only ever directly made syscalls for pleasure, not for business, but understanding what strace is talking about is very helpful every now and then
>>
>>107817731
l-lewd >_<
>>
>>107813965
finally i good bread that i can enjoy
thank 4 bake OP
>>
File: 1754601547569893.jpg (27 KB, 498x338)
27 KB
27 KB JPG
>>107813965
based bread
i am yet to write any syscalls outside of schoolwork despite working on linux device drivers for work because i'm only ever in kernel space :^)



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.