Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_file.c
Show First 20 Lines • Show All 726 Lines • ▼ Show 20 Lines | linux_unlink(struct thread *td, struct linux_unlink_args *args) | ||||
struct stat st; | struct stat st; | ||||
if (!LUSECONVPATH(td)) { | if (!LUSECONVPATH(td)) { | ||||
error = kern_funlinkat(td, AT_FDCWD, args->path, FD_NONE, | error = kern_funlinkat(td, AT_FDCWD, args->path, FD_NONE, | ||||
UIO_USERSPACE, 0, 0); | UIO_USERSPACE, 0, 0); | ||||
if (error == EPERM) { | if (error == EPERM) { | ||||
/* Introduce POSIX noncompliant behaviour of Linux */ | /* Introduce POSIX noncompliant behaviour of Linux */ | ||||
if (kern_statat(td, 0, AT_FDCWD, args->path, | if (kern_statat(td, 0, AT_FDCWD, args->path, | ||||
UIO_USERSPACE, &st, NULL) == 0) { | UIO_USERSPACE, &st) == 0) { | ||||
if (S_ISDIR(st.st_mode)) | if (S_ISDIR(st.st_mode)) | ||||
error = EISDIR; | error = EISDIR; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
LCONVPATHEXIST(args->path, &path); | LCONVPATHEXIST(args->path, &path); | ||||
error = kern_funlinkat(td, AT_FDCWD, path, FD_NONE, UIO_SYSSPACE, 0, 0); | error = kern_funlinkat(td, AT_FDCWD, path, FD_NONE, UIO_SYSSPACE, 0, 0); | ||||
if (error == EPERM) { | if (error == EPERM) { | ||||
/* Introduce POSIX noncompliant behaviour of Linux */ | /* Introduce POSIX noncompliant behaviour of Linux */ | ||||
if (kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st, | if (kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, | ||||
NULL) == 0) { | &st) == 0) { | ||||
if (S_ISDIR(st.st_mode)) | if (S_ISDIR(st.st_mode)) | ||||
error = EISDIR; | error = EISDIR; | ||||
} | } | ||||
} | } | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
} | } | ||||
return (error); | return (error); | ||||
Show All 9 Lines | linux_unlinkat_impl(struct thread *td, enum uio_seg pathseg, const char *path, | ||||
if (args->flag & LINUX_AT_REMOVEDIR) | if (args->flag & LINUX_AT_REMOVEDIR) | ||||
error = kern_frmdirat(td, dfd, path, FD_NONE, pathseg, 0); | error = kern_frmdirat(td, dfd, path, FD_NONE, pathseg, 0); | ||||
else | else | ||||
error = kern_funlinkat(td, dfd, path, FD_NONE, pathseg, 0, 0); | error = kern_funlinkat(td, dfd, path, FD_NONE, pathseg, 0, 0); | ||||
if (error == EPERM && !(args->flag & LINUX_AT_REMOVEDIR)) { | if (error == EPERM && !(args->flag & LINUX_AT_REMOVEDIR)) { | ||||
/* Introduce POSIX noncompliant behaviour of Linux */ | /* Introduce POSIX noncompliant behaviour of Linux */ | ||||
if (kern_statat(td, AT_SYMLINK_NOFOLLOW, dfd, path, | if (kern_statat(td, AT_SYMLINK_NOFOLLOW, dfd, path, | ||||
pathseg, &st, NULL) == 0 && S_ISDIR(st.st_mode)) | pathseg, &st) == 0 && S_ISDIR(st.st_mode)) | ||||
error = EISDIR; | error = EISDIR; | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
linux_unlinkat(struct thread *td, struct linux_unlinkat_args *args) | linux_unlinkat(struct thread *td, struct linux_unlinkat_args *args) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,331 Lines • Show Last 20 Lines |