[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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1752091526597864.jpg (366 KB, 1080x900)
366 KB
366 KB JPG
previous: >>108316723

#define __NR_chdir                80
#define __NR_fchdir 81

https://man7.org/linux/man-pages/man2/chdir.2.html

tl;dr:
change your working directory

wow, speak of the devil. these syscalls have an incredibly simple API. so there's really not much to say about them lol. maybe more discussion could be had on path resolution...
https://man7.org/linux/man-pages/man7/path_resolution.7.html
this subject is a good bit more complex, so there's lots to talk about

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/
>>
The ONLY usecase for these is for starting a new process with a different working dir. No program should move itself around otherwise.
>>
>>108323235
i think you'd probably want it if you chroot, as well, wouldn't you?
>>
>>108323247
Yes. If you chroot(2) without then calling chdir("/") then you can escape the chroot by accessing files in your current working directory, which may be outside the chroot. This is especially bad for system daemons, whose current working typically begins as "/", as this pretty much totally negates the security benefits of chroot(2), allowing you to access any file on the filesystem normally.
>>
pure love with syscalls anon
>>
>>108323501
yay this one is cute!!
which syscall do you think would be the best at demonstrating its love?
>>
>>108323524
sleep(2) with syscalls anon
sync(2) with syscalls anon
>>
File: monster.jpg (402 KB, 987x1400)
402 KB
402 KB JPG
>>108323363
nice, good to know
>>
>>108323592
hmmm now im curious what the lewdest syscalls are

>pure sex tier:
#define __NR_pipe                22
#define __NR_bind 49
#define __NR_mount 165
#define __NR_mbind 237
#define __NR_pipe2 293
#define __NR_move_mount 429

>sounds kinda lewd tier:
#define __NR_access                21
#define __NR_socket 41
#define __NR_fork 57
#define __NR_link 86
#define __NR_getppid 110
#define __NR_getpgrp 111
#define __NR_uselib 134
#define __NR_swapon 167
#define __NR_swapoff 168
#define __NR_io_submit 209
#define __NR_openat 257
#define __NR_faccessat 269
#define __NR_openat2 437
#define __NR_faccessat2 439
#define __NR_mount_setattr 442

>pure love tier:
#define __NR_mprotect            10
#define __NR_select 23
#define __NR_madvise 28
#define __NR_connect 42
#define __NR_accept 43
#define __NR_listen 50
#define __NR_wait4 61
#define __NR_personality 135
#define __NR_setpriority 141
#define __NR_security 185
#define __NR_accept4 288

>sadness and abuse tier:
#define __NR_brk                12
#define __NR_dup 32
#define __NR_shutdown 48
#define __NR_kill 62
#define __NR_vhangup 153
#define __NR_tkill 200
#define __NR_tgkill 234
#define __NR_landlock_create_ruleset 444
#define __NR_landlock_add_rule 445
>>
>>108323183
Anyone know where I can get one of those nipples? For curiosity's sake.
>>
>>108323759
why is pipe(2) pure sex?
>>
>>108323799
pipe is a slang term for fuck
so you can pipe someone in the same way you'd fuck them
>>
File: hmm.png (610 B, 60x60)
610 B
610 B PNG
>>108323848
ohh i see. so you're not so pure then, aren't you?
>>
>>108323893
probably not i guess haha
i am still anti sex though!
>>
>>108323905
why is that, if i may ask?
>>
>>108323919
hmmm, hard to say
it's kind of just icky and confusing and a lot of work, and in the end it doesn't even feel good! so why would anyone ever bother?
>>
>>108323967
are you speaking from experience here anon?
>>
Last thread I mentioned this so I'll keep banging the drum that running "cd .." DOES NOT execute chdir("..") because of directory symlinks
$ cd /tmp
$ mkdir dir
$ ln -s .. dir/dir
$ cd dir/dir/dir/dir/dir/dir/dir/dir/dir
$ pwd -P
/tmp/dir
$ pwd -L
/tmp/dir/dir/dir/dir/dir/dir/dir/dir/dir
$ python3 -c 'import os; print(os.environ["PWD"]); print(os.getcwd()); os.chdir(".."); print(os.getcwd())'
/tmp/dir/dir/dir/dir/dir/dir/dir/dir/dir
/tmp/dir
/tmp
$ strace -e chdir sh -c 'cd ..'
chdir("/tmp/dir/dir/dir/dir/dir/dir/dir/dir") = 0
+++ exited with 0 +++

or even worse
$ ln -s /var/log
$ sh -c 'cd log/..; pwd'
/tmp
$ python3 -c 'import os; print(os.getcwd()); os.chdir("log/.."); print(os.getcwd())'
/tmp
/var
$ ln -s /var/log

So the intuitions you've built cd'ing around in your shell may not match the harsh syscall reality
>>
>>108323987
oh, yeah, i have tried it a couple times to make sure i didn't like it, and i was correct that i did not like it
>>
>>108323995
>ln -s .. dir/dir
what the fuck? can you even do this? i always thought those special dentries were, well... special
>>
>>108323997
curious, i'll just hope that someday you'll find someone who will make you enjoy it
>>
>>108324026
it's okay! i don't really want it anyway. i would rather find someone to discuss syscalls with and maybe cuddle or potentially kiss, though that might be rare
>>
>>108324009
.. is the source, not the target
The command creates a symlink at dir/dir that points to ".." (which unlike typical commands is resolved relative to its own containing directory and not the directory where you run ln)
It would have been cleaner to link "." now that I think of it, linking ".." means that as you go deeper into it you alternate between being in /tmp and being into /tmp/dir
It's possible that directory symlinks were a mistake
>>
>>108324050
can you bind mount overtop of ".."? or would that be nonsensical? i mean, it would definitely be nonsensical, but linux lets you do lots of nonsensical things
>>
>>108324033
yeah it's totally possible to live without it, though people are usually happier when they have it in their lives.
so i guess you're also lonely, too? otherwise you probably wouldn't be so starving for attention lol
>>
>>108324058
mount(1) seems to resolve ".." to the actual parent directory and mounts it on top of that.
The most obvious fun thing that happens is that your current directory becomes unreachable, 'cd $PWD' fails, etcetera.
The inode of ".." also changes:
$ ls -ia
4056 ./ 44040193 ../
$ sudo umount ..
$ ls -ia
4056 ./ 4040 ../

I guess it's common enough for ".." to be another filesystem and this is just an instance of that? (Current directory is in tmpfs, linked directory is on a disk.) But I don't even know how that works internally
>>
>>108324116
i might have to look into this more when i have some time. seems like an interesting edge case
>>108324114
well, aren't we all a little attention starved these days? what, with the breakdown of cultural ties, the atomization of society, etc. we're all looking for a some
connect()
ion
>>
>>108323740
>spent 45 minutes in photoshop
>nobody noticed my pic

:(
>>
>>108324201
i noticed it and thought it was amusing, if a bit crude lol
>>
>>108324208
thank you and good luck with the syscalls
>>
>>108324201
we did notice it, good pic anon
>>
File: 1760026819933300.png (522 KB, 1441x677)
522 KB
522 KB PNG
>>108323771
Richell Can Milk Nipple
it's on amazon. don't forget to buy some adult diapers to go with it.
>>
>>108324404
fucking hell, thirty bucks
>>
>>108324133
yeah, very true for me
>>
>>108323740
>>108324201
I honestly chuckled for a good couple of seconds. Thank you anon
>>
>>108324457
550 yen for japanese people
reseller is making a lot of money
>>
>>108324404
>30 USD
Fucking hell nevermind
>>
honestly i should just drop the cope, stop lying to myself, and buy a sippy cup
>>
>>108324752
what's stopping you from drinking from a regular cup?
>>
do you implement all of that or do you jus tmake posts
>>
>>108324761
nothing. i just think i would prefer sipping. i have a bit of an oral fixation i suppose, and having something to chew on/sip at would satisfy that
>>108324768
do i implement all of what? syscalls? no lol. i have used some raw syscalls before, but i don't do it every time i make a thread. too busy with work for that, unfortunately. maybe if i were independently wealthy or something
>>
>>108324780
funny anon
>>
File: 1766443185683150.jpg (86 KB, 736x736)
86 KB
86 KB JPG
>>108324811
i wasn't joking.....
>>
File: 1724939363630617.png (22 KB, 197x341)
22 KB
22 KB PNG
>>108324819
i know
>>
The syscall threads are the only reason I keep using /g/. They are always very wholesome.
>>
>>108325753
They are really not. OP always posts some bait tranime image that gets a bunch of degenerates to make lewd comments, and not much discussion gets had.
>>
>>108326091
you sound like a bitter halfwit jeet, now please go back.
>>
>>108326091
it's unfortunate that it's been hard to keep stuff bumped during the weekdays these past few weeks...
>>
>>108326091
The lewd and flirty comments have only started about two threads ago, before that wasn't the case, and now I would say that the flirting is a net positive for the threads.
>>
bampu
>>
>>108323799
She gets spitroasted from both sides regularly.
>>
>>108323759
pipe2 electric boogaloo
>>
File: 1741444106002579.jpg (57 KB, 735x551)
57 KB
57 KB JPG
>>108327894
n-no...
>>
>>108326386
the flirting was already the case in late january threads iirc
OP always replies to these, too
>>108327894
good
>>
>>108323759
Awwww, the pure love ones are reallly cute. Thanks anon.
>>
>>108329483
no problem
i really liked them too hehe
i have gone back and read through the list a few times, just because they are so cozy/adorable
>>
>>108323183
>>108323759
What does the NR stand for? Also is this C code? These are called constants right? Why is it written in C? I know some C just wondering.
>>
>>108331627
AFAIK the NR stands for number, because the constant is each syscall's number. Also, yes this is C preprocessor directives.
>>
>>108332087
Ok. Thanks.
>>
>>108323759
If you leave linux for a minute then,
/* syscall: "pledge" ret: "int" args: "const char *" "const char *" */
#define SYS_pledge 108

from OpenBSD is pretty lovey dovey too.
>>
>>108333716
oh my god this is so cute i love it ;___;



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