Page MenuHomeFreeBSD

kern_linkat: modify to accept AT_ flags instead of FOLLOW/NOFOLLOW
ClosedPublic

Authored by trasz on Apr 15 2021, 1:32 PM.
Tags
None
Referenced Files
F107351829: D29776.diff
Sun, Jan 12, 9:59 PM
Unknown Object (File)
Dec 6 2024, 4:46 PM
Unknown Object (File)
Dec 2 2024, 4:40 PM
Unknown Object (File)
Nov 10 2024, 9:48 PM
Unknown Object (File)
Nov 7 2024, 11:48 AM
Unknown Object (File)
Nov 4 2024, 7:51 PM
Unknown Object (File)
Oct 24 2024, 1:56 AM
Unknown Object (File)
Oct 18 2024, 10:16 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38593
Build 35482: arc lint + arc unit

Event Timeline

trasz requested review of this revision.Apr 15 2021, 1:32 PM

Not that it's not tested yet; advice on how to exercise this functionality is welcome.

You should write (or find existing) test that uses linkat(AT_SYMLINK_FOLLOW) and linkat(0) on the symlink. In first case the link to the target should be created, in the second case perhaps error is returned (not sure which).

This revision is now accepted and ready to land.Apr 15 2021, 1:57 PM

Okay, it appears to work; I've tested with linkat_test, and also this:

#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int
main(int argc, char **argv)
{
int error;

error = linkat(AT_FDCWD, "name1", AT_FDCWD, "name2-bez-linkat", 0);
perror("linkat");

error = linkat(AT_FDCWD, "name1", AT_FDCWD, "name2-z-linkat", AT_SYMLINK_FOLLOW);
perror("linkat");


return (0);
}

Result, in both cases (with, and without the patch), is:

lrwx------  2 trasz  trasz    11 Apr 25 14:08 name2-bez-linkat -> /etc/passwd
-rw-r--r--  2 root   wheel  3801 Mar 30 14:42 name2-z-linkat