[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: 1766077501980664.jpg (228 KB, 1080x1080)
228 KB
228 KB JPG
previous: >>107824139

#define __NR_lseek                8


now this is an interesting one. it feels a bit strange to have a separate file offset whose information is stored in a totally opaque container, where you can only query information about it via some API. not to mention the following:
>If the O_APPEND file status flag is set on the open file description, then a write(2) always moves the file offset to the end of the file, regardless of the use of lseek().
>Some devices are incapable of seeking and POSIX does not specify which devices must support lseek().

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/
>>
it would appear that L'Seek is not very popular
>>
why even use a syscall can't just do the hardware yourself would be faster instead of waiting for the kernal what if its busy doing other things like internet
>>
You'll get bored of this after a week
>>
>>107834380
potentially, but i'm hoping to keep it up for as long as possible
>>
sój thread
>>
>>107833909
nice fat anime breasts
>>
>>107834589
thanks i have been told she's just like me fr
>>
>>107833909
name of anime?
>>
>>107833909
anybody here use or know about eBPF? Sounds really cool, sending instructions to a virtual machine inside the kernel. Of course, I can barely program in userspace, I have no idea what I would do in the kernel space, but one day I'll get there. I have to learn syscalls and C, then I can start.
>>
>>107835319
Bubblegum Crysis
>>
>>107835319
Bubblecoom Crisis
>>
>>107834373
in linux, everything is a file. you can't just use hardware apis but have to go through an abstraction (which will just tell you that the operation isn't supported for non-files)
>>
>>107833909
i nominate mmap as tomorrow's syscall, as it is the best syscall of all time. the design of bsd's virtual memory system is brilliant
>>
>>107834373
everything would have to be done in kernel mode if you were to do things this way and a big benefit of kernel mediating all requests for device ops is it handles the scheduling. stuff like networking doesn't freeze the kernel either, the operation is performed by a device separate from your cpu and will just r/w data to some kernel-reserved portion of ram while your cpu executes other things. disk ops also take a lot of time but since they happen asynchronously the kernel can block your process and pass cpu time off to another process while waiting

basically without syscalls you wouldn't have any protections or abstractions or much of an os at all, it wouldn't be faster, programming would be hell and performance would be abysmal

there's definitely more nuance to everything but that's the best general answer i can bother to write
>>
Another really good resource for syscall programming is the nolibc library in the linux kernel source code.

https://github.com/torvalds/linux/tree/master/tools/include/nolibc

Each arch_***.h file shows how to make a syscall on different architectures, and sometimes there's interesting comments or interesting examples that show how a minimal libc implementation could be written on-top of syscalls.

I wrote a bunch of syscall-only programs because you can copy the executable into a virtual filesystem as "/bin/init" and it will run by itself with nothing else on-top of a linux kernel. A tar file with just that one executable can be imported into Windows WSL as it's own standalone linux distro and then you can brag and say "yeah I wrote my own linux distro from scratch. It calls you a random slur and then crashes".

programming with syscalls kind of blows because it's hyped as "stable" so you would think the man pages have like 20+ years of polish but they still suck.

> lseek man page doesn't say if off_t is 32-bits or 64-bits, or if it's signed or unsigned
> man page for off_t only says it's a "signed integer (as specified under POSIX 2001)"
> find POSIX 2001 docs, search for a while, find the specification of off_t
> "off_t is a signed integer"
>>
>>107837104
i agree that it is indeed the best syscall of all time. luckily for us, it also is the next one in line



[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.