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
F82015486: D29776.diff
Wed, Apr 24, 1:58 PM
Unknown Object (File)
Jan 17 2024, 11:13 PM
Unknown Object (File)
Jan 9 2024, 9:09 AM
Unknown Object (File)
Dec 22 2023, 9:56 PM
Unknown Object (File)
Dec 20 2023, 12:29 AM
Unknown Object (File)
Dec 16 2023, 11:47 PM
Unknown Object (File)
Nov 30 2023, 10:39 PM
Unknown Object (File)
Nov 25 2023, 11:37 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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