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
Unknown Object (File)
Fri, Jan 24, 5:02 PM
Unknown Object (File)
Mon, Jan 13, 1:27 AM
Unknown Object (File)
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
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