Add 3436 file system regression tests in 184 files.
Almost all regression tests are based on very flexible fstest tool. They verify correctness (POSIX conformance) of almost all file system-related system calls. The motivation behind this work is my ZFS port and POSIX, who doesn't provide free test suites. Runs on: FreeBSD/UFS, FreeBSD/ZFS, Solaris/UFS, Solaris/ZFS To try it out: # cd fstest # make # find tests/* -type d | xargs prove
This commit is contained in:
parent
ebfaa05056
commit
53feb1d422
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=166065
27
tools/regression/fstest/LICENSE
Normal file
27
tools/regression/fstest/LICENSE
Normal file
@ -0,0 +1,27 @@
|
||||
$FreeBSD$
|
||||
|
||||
License for all regression tests available with fstest:
|
||||
|
||||
Copyright (c) 2006-2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
15
tools/regression/fstest/Makefile
Normal file
15
tools/regression/fstest/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# $FreeBSD$
|
||||
|
||||
CFLAGS+=-DHAS_LCHMOD
|
||||
CFLAGS+=-DHAS_CHFLAGS
|
||||
CFLAGS+=-DHAS_LCHFLAGS
|
||||
#CFLAGS+=-DHAS_TRUNCATE64
|
||||
#CFLAGS+=-DHAS_STAT64
|
||||
|
||||
all: fstest
|
||||
|
||||
fstest: fstest.c
|
||||
gcc -Wall ${CFLAGS} fstest.c -o fstest
|
||||
|
||||
clean:
|
||||
rm -f fstest
|
995
tools/regression/fstest/fstest.c
Normal file
995
tools/regression/fstest/fstest.c
Normal file
@ -0,0 +1,995 @@
|
||||
/*-
|
||||
* Copyright (c) 2006-2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef HAS_TRUNCATE64
|
||||
#define truncate64 truncate
|
||||
#endif
|
||||
#ifndef HAS_STAT64
|
||||
#define stat64 stat
|
||||
#define lstat64 lstat
|
||||
#endif
|
||||
|
||||
#ifndef ALLPERMS
|
||||
#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
|
||||
#endif
|
||||
|
||||
enum action {
|
||||
ACTION_OPEN,
|
||||
ACTION_CREATE,
|
||||
ACTION_UNLINK,
|
||||
ACTION_MKDIR,
|
||||
ACTION_RMDIR,
|
||||
ACTION_LINK,
|
||||
ACTION_SYMLINK,
|
||||
ACTION_RENAME,
|
||||
ACTION_MKFIFO,
|
||||
ACTION_CHMOD,
|
||||
#ifdef HAS_LCHMOD
|
||||
ACTION_LCHMOD,
|
||||
#endif
|
||||
ACTION_CHOWN,
|
||||
ACTION_LCHOWN,
|
||||
#ifdef HAS_CHFLAGS
|
||||
ACTION_CHFLAGS,
|
||||
#endif
|
||||
#ifdef HAS_LCHFLAGS
|
||||
ACTION_LCHFLAGS,
|
||||
#endif
|
||||
ACTION_TRUNCATE,
|
||||
ACTION_STAT,
|
||||
ACTION_LSTAT,
|
||||
};
|
||||
|
||||
#define TYPE_NONE 0x0000
|
||||
#define TYPE_STRING 0x0001
|
||||
#define TYPE_NUMBER 0x0002
|
||||
|
||||
#define TYPE_OPTIONAL 0x0100
|
||||
|
||||
#define MAX_ARGS 8
|
||||
|
||||
struct syscall_desc {
|
||||
char *sd_name;
|
||||
enum action sd_action;
|
||||
int sd_args[MAX_ARGS];
|
||||
};
|
||||
|
||||
static struct syscall_desc syscalls[] = {
|
||||
{ "open", ACTION_OPEN, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } },
|
||||
{ "create", ACTION_CREATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "unlink", ACTION_UNLINK, { TYPE_STRING, TYPE_NONE } },
|
||||
{ "mkdir", ACTION_MKDIR, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "rmdir", ACTION_RMDIR, { TYPE_STRING, TYPE_NONE } },
|
||||
{ "link", ACTION_LINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
#ifdef HAS_LCHMOD
|
||||
{ "lchmod", ACTION_LCHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
#endif
|
||||
{ "chown", ACTION_CHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "lchown", ACTION_LCHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } },
|
||||
#ifdef HAS_CHFLAGS
|
||||
{ "chflags", ACTION_CHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
#endif
|
||||
#ifdef HAS_LCHFLAGS
|
||||
{ "lchflags", ACTION_LCHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
#endif
|
||||
{ "truncate", ACTION_TRUNCATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "stat", ACTION_STAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ "lstat", ACTION_LSTAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ NULL, -1, { TYPE_NONE } }
|
||||
};
|
||||
|
||||
struct flag {
|
||||
long long f_flag;
|
||||
char *f_str;
|
||||
};
|
||||
|
||||
static struct flag open_flags[] = {
|
||||
#ifdef O_RDONLY
|
||||
{ O_RDONLY, "O_RDONLY" },
|
||||
#endif
|
||||
#ifdef O_WRONLY
|
||||
{ O_WRONLY, "O_WRONLY" },
|
||||
#endif
|
||||
#ifdef O_RDWR
|
||||
{ O_RDWR, "O_RDWR" },
|
||||
#endif
|
||||
#ifdef O_NONBLOCK
|
||||
{ O_NONBLOCK, "O_NONBLOCK" },
|
||||
#endif
|
||||
#ifdef O_APPEND
|
||||
{ O_APPEND, "O_APPEND" },
|
||||
#endif
|
||||
#ifdef O_CREAT
|
||||
{ O_CREAT, "O_CREAT" },
|
||||
#endif
|
||||
#ifdef O_TRUNC
|
||||
{ O_TRUNC, "O_TRUNC" },
|
||||
#endif
|
||||
#ifdef O_EXCL
|
||||
{ O_EXCL, "O_EXCL" },
|
||||
#endif
|
||||
#ifdef O_SHLOCK
|
||||
{ O_SHLOCK, "O_SHLOCK" },
|
||||
#endif
|
||||
#ifdef O_EXLOCK
|
||||
{ O_EXLOCK, "O_EXLOCK" },
|
||||
#endif
|
||||
#ifdef O_DIRECT
|
||||
{ O_DIRECT, "O_DIRECT" },
|
||||
#endif
|
||||
#ifdef O_FSYNC
|
||||
{ O_FSYNC, "O_FSYNC" },
|
||||
#endif
|
||||
#ifdef O_SYNC
|
||||
{ O_SYNC, "O_SYNC" },
|
||||
#endif
|
||||
#ifdef O_NOFOLLOW
|
||||
{ O_NOFOLLOW, "O_NOFOLLOW" },
|
||||
#endif
|
||||
#ifdef O_NOCTTY
|
||||
{ O_NOCTTY, "O_NOCTTY" },
|
||||
#endif
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#ifdef HAS_CHFLAGS
|
||||
static struct flag chflags_flags[] = {
|
||||
#ifdef UF_NODUMP
|
||||
{ UF_NODUMP, "UF_NODUMP" },
|
||||
#endif
|
||||
#ifdef UF_IMMUTABLE
|
||||
{ UF_IMMUTABLE, "UF_IMMUTABLE" },
|
||||
#endif
|
||||
#ifdef UF_APPEND
|
||||
{ UF_APPEND, "UF_APPEND" },
|
||||
#endif
|
||||
#ifdef UF_NOUNLINK
|
||||
{ UF_NOUNLINK, "UF_NOUNLINK" },
|
||||
#endif
|
||||
#ifdef UF_OPAQUE
|
||||
{ UF_OPAQUE, "UF_OPAQUE" },
|
||||
#endif
|
||||
#ifdef SF_ARCHIVED
|
||||
{ SF_ARCHIVED, "SF_ARCHIVED" },
|
||||
#endif
|
||||
#ifdef SF_IMMUTABLE
|
||||
{ SF_IMMUTABLE, "SF_IMMUTABLE" },
|
||||
#endif
|
||||
#ifdef SF_APPEND
|
||||
{ SF_APPEND, "SF_APPEND" },
|
||||
#endif
|
||||
#ifdef SF_NOUNLINK
|
||||
{ SF_NOUNLINK, "SF_NOUNLINK" },
|
||||
#endif
|
||||
#ifdef SF_SNAPSHOT
|
||||
{ SF_SNAPSHOT, "SF_SNAPSHOT" },
|
||||
#endif
|
||||
{ 0, NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char *err2str(int error);
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
fprintf(stderr, "usage: fstest [-u uid] [-g gid1[,gid2[...]]] syscall args ...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static long long
|
||||
str2flags(struct flag *tflags, char *sflags)
|
||||
{
|
||||
long long flags = 0;
|
||||
unsigned int i;
|
||||
char *f;
|
||||
|
||||
for (f = strtok(sflags, ","); f != NULL; f = strtok(NULL, ",")) {
|
||||
/* Support magic 'none' flag which just reset all flags. */
|
||||
if (strcmp(f, "none") == 0)
|
||||
return (0);
|
||||
for (i = 0; tflags[i].f_str != NULL; i++) {
|
||||
if (strcmp(tflags[i].f_str, f) == 0)
|
||||
break;
|
||||
}
|
||||
if (tflags[i].f_str == NULL) {
|
||||
fprintf(stderr, "unknown flag '%s'\n", f);
|
||||
exit(1);
|
||||
}
|
||||
flags |= tflags[i].f_flag;
|
||||
}
|
||||
return (flags);
|
||||
}
|
||||
|
||||
#ifdef HAS_CHFLAGS
|
||||
static char *
|
||||
flags2str(struct flag *tflags, long long flags)
|
||||
{
|
||||
static char sflags[1024];
|
||||
unsigned int i;
|
||||
|
||||
sflags[0] = '\0';
|
||||
for (i = 0; tflags[i].f_str != NULL; i++) {
|
||||
if (flags & tflags[i].f_flag) {
|
||||
if (sflags[0] != '\0')
|
||||
strlcat(sflags, ",", sizeof(sflags));
|
||||
strlcat(sflags, tflags[i].f_str, sizeof(sflags));
|
||||
}
|
||||
}
|
||||
if (sflags[0] == '\0')
|
||||
strlcpy(sflags, "none", sizeof(sflags));
|
||||
return (sflags);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct syscall_desc *
|
||||
find_syscall(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; syscalls[i].sd_name != NULL; i++) {
|
||||
if (strcmp(syscalls[i].sd_name, name) == 0)
|
||||
return (&syscalls[i]);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
show_stat(struct stat64 *sp, const char *what)
|
||||
{
|
||||
|
||||
if (strcmp(what, "mode") == 0)
|
||||
printf("0%o", (unsigned int)(sp->st_mode & ALLPERMS));
|
||||
else if (strcmp(what, "inode") == 0)
|
||||
printf("%lld", (long long)sp->st_ino);
|
||||
else if (strcmp(what, "nlink") == 0)
|
||||
printf("%lld", (long long)sp->st_nlink);
|
||||
else if (strcmp(what, "uid") == 0)
|
||||
printf("%d", (int)sp->st_uid);
|
||||
else if (strcmp(what, "gid") == 0)
|
||||
printf("%d", (int)sp->st_gid);
|
||||
else if (strcmp(what, "size") == 0)
|
||||
printf("%lld", (long long)sp->st_size);
|
||||
else if (strcmp(what, "blocks") == 0)
|
||||
printf("%lld", (long long)sp->st_blocks);
|
||||
else if (strcmp(what, "atime") == 0)
|
||||
printf("%lld", (long long)sp->st_atime);
|
||||
else if (strcmp(what, "mtime") == 0)
|
||||
printf("%lld", (long long)sp->st_mtime);
|
||||
else if (strcmp(what, "ctime") == 0)
|
||||
printf("%lld", (long long)sp->st_ctime);
|
||||
#ifdef HAS_CHFLAGS
|
||||
else if (strcmp(what, "flags") == 0)
|
||||
printf("%s", flags2str(chflags_flags, sp->st_flags));
|
||||
#endif
|
||||
else if (strcmp(what, "type") == 0) {
|
||||
switch (sp->st_mode & S_IFMT) {
|
||||
case S_IFIFO:
|
||||
printf("fifo");
|
||||
break;
|
||||
case S_IFCHR:
|
||||
printf("char");
|
||||
break;
|
||||
case S_IFDIR:
|
||||
printf("dir");
|
||||
break;
|
||||
case S_IFBLK:
|
||||
printf("block");
|
||||
break;
|
||||
case S_IFREG:
|
||||
printf("regular");
|
||||
break;
|
||||
case S_IFLNK:
|
||||
printf("symlink");
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
printf("socket");
|
||||
break;
|
||||
default:
|
||||
printf("unknown");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
printf("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
show_stats(struct stat64 *sp, char *what)
|
||||
{
|
||||
const char *s = "";
|
||||
char *w;
|
||||
|
||||
for (w = strtok(what, ","); w != NULL; w = strtok(NULL, ",")) {
|
||||
printf("%s", s);
|
||||
show_stat(sp, w);
|
||||
s = ",";
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
call_syscall(struct syscall_desc *scall, char *argv[])
|
||||
{
|
||||
struct stat64 sb;
|
||||
long long flags;
|
||||
unsigned int i;
|
||||
char *endp;
|
||||
int rval;
|
||||
union {
|
||||
char *str;
|
||||
long long num;
|
||||
} args[MAX_ARGS];
|
||||
|
||||
/*
|
||||
* Verify correctness of the arguments.
|
||||
*/
|
||||
for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) {
|
||||
if (scall->sd_args[i] == TYPE_NONE) {
|
||||
if (argv[i] == NULL || strcmp(argv[i], ":") == 0)
|
||||
break;
|
||||
fprintf(stderr, "too many arguments [%s]\n", argv[i]);
|
||||
exit(1);
|
||||
} else {
|
||||
if (argv[i] == NULL || strcmp(argv[i], ":") == 0) {
|
||||
if (scall->sd_args[i] & TYPE_OPTIONAL)
|
||||
break;
|
||||
fprintf(stderr, "too few arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
if (scall->sd_args[i] & TYPE_STRING) {
|
||||
if (strcmp(argv[i], "NULL") == 0)
|
||||
args[i].str = NULL;
|
||||
else if (strcmp(argv[i], "DEADCODE") == 0)
|
||||
args[i].str = (void *)0xdeadc0de;
|
||||
else
|
||||
args[i].str = argv[i];
|
||||
} else if (scall->sd_args[i] & TYPE_NUMBER) {
|
||||
args[i].num = strtoll(argv[i], &endp, 0);
|
||||
if (*endp != '\0' && !isspace((unsigned char)*endp)) {
|
||||
fprintf(stderr, "invalid argument %u, number expected [%s]\n", i, endp);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Call the given syscall.
|
||||
*/
|
||||
#define NUM(n) (args[(n)].num)
|
||||
#define STR(n) (args[(n)].str)
|
||||
switch (scall->sd_action) {
|
||||
case ACTION_OPEN:
|
||||
flags = str2flags(open_flags, STR(1));
|
||||
if (flags & O_CREAT) {
|
||||
if (i == 2) {
|
||||
fprintf(stderr, "too few arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
rval = open(STR(0), flags, (mode_t)NUM(2));
|
||||
} else {
|
||||
if (i == 3) {
|
||||
fprintf(stderr, "too many arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
rval = open(STR(0), flags);
|
||||
}
|
||||
break;
|
||||
case ACTION_CREATE:
|
||||
rval = open(STR(0), O_CREAT | O_EXCL, NUM(1));
|
||||
if (rval >= 0)
|
||||
close(rval);
|
||||
break;
|
||||
case ACTION_UNLINK:
|
||||
rval = unlink(STR(0));
|
||||
break;
|
||||
case ACTION_MKDIR:
|
||||
rval = mkdir(STR(0), NUM(1));
|
||||
break;
|
||||
case ACTION_RMDIR:
|
||||
rval = rmdir(STR(0));
|
||||
break;
|
||||
case ACTION_LINK:
|
||||
rval = link(STR(0), STR(1));
|
||||
break;
|
||||
case ACTION_SYMLINK:
|
||||
rval = symlink(STR(0), STR(1));
|
||||
break;
|
||||
case ACTION_RENAME:
|
||||
rval = rename(STR(0), STR(1));
|
||||
break;
|
||||
case ACTION_MKFIFO:
|
||||
rval = mkfifo(STR(0), NUM(1));
|
||||
break;
|
||||
case ACTION_CHMOD:
|
||||
rval = chmod(STR(0), NUM(1));
|
||||
break;
|
||||
#ifdef HAS_LCHMOD
|
||||
case ACTION_LCHMOD:
|
||||
rval = lchmod(STR(0), NUM(1));
|
||||
break;
|
||||
#endif
|
||||
case ACTION_CHOWN:
|
||||
rval = chown(STR(0), NUM(1), NUM(2));
|
||||
break;
|
||||
case ACTION_LCHOWN:
|
||||
rval = lchown(STR(0), NUM(1), NUM(2));
|
||||
break;
|
||||
#ifdef HAS_CHFLAGS
|
||||
case ACTION_CHFLAGS:
|
||||
rval = chflags(STR(0), str2flags(chflags_flags, STR(1)));
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAS_LCHFLAGS
|
||||
case ACTION_LCHFLAGS:
|
||||
rval = lchflags(STR(0), str2flags(chflags_flags, STR(1)));
|
||||
break;
|
||||
#endif
|
||||
case ACTION_TRUNCATE:
|
||||
rval = truncate64(STR(0), NUM(1));
|
||||
break;
|
||||
case ACTION_STAT:
|
||||
rval = stat64(STR(0), &sb);
|
||||
if (rval == 0) {
|
||||
show_stats(&sb, STR(1));
|
||||
return (i);
|
||||
}
|
||||
break;
|
||||
case ACTION_LSTAT:
|
||||
rval = lstat64(STR(0), &sb);
|
||||
if (rval == 0) {
|
||||
show_stats(&sb, STR(1));
|
||||
return (i);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unsupported syscall\n");
|
||||
exit(1);
|
||||
}
|
||||
#undef STR
|
||||
#undef NUM
|
||||
if (rval < 0) {
|
||||
const char *serrno;
|
||||
|
||||
serrno = err2str(errno);
|
||||
fprintf(stderr, "%s returned %d\n", scall->sd_name, rval);
|
||||
printf("%s\n", serrno);
|
||||
exit(1);
|
||||
}
|
||||
printf("0\n");
|
||||
return (i);
|
||||
}
|
||||
|
||||
static void
|
||||
set_gids(char *gids)
|
||||
{
|
||||
gid_t *gidset;
|
||||
long ngroups;
|
||||
char *g, *endp;
|
||||
unsigned i;
|
||||
|
||||
ngroups = sysconf(_SC_NGROUPS_MAX);
|
||||
assert(ngroups > 0);
|
||||
gidset = malloc(sizeof(*gidset) * ngroups);
|
||||
assert(gidset != NULL);
|
||||
for (i = 0, g = strtok(gids, ","); g != NULL; g = strtok(NULL, ","), i++) {
|
||||
if (i >= ngroups) {
|
||||
fprintf(stderr, "too many gids\n");
|
||||
exit(1);
|
||||
}
|
||||
gidset[i] = strtol(g, &endp, 0);
|
||||
if (*endp != '\0' && !isspace((unsigned char)*endp)) {
|
||||
fprintf(stderr, "invalid gid '%s' - number expected\n",
|
||||
g);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (setgroups(i, gidset) < 0) {
|
||||
fprintf(stderr, "cannot change groups: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
free(gidset);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct syscall_desc *scall;
|
||||
unsigned int n;
|
||||
char *gids, *endp;
|
||||
int uid, umsk, ch;
|
||||
|
||||
uid = -1;
|
||||
gids = NULL;
|
||||
umsk = 0;
|
||||
|
||||
while ((ch = getopt(argc, argv, "g:u:U:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'g':
|
||||
gids = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
uid = (int)strtol(optarg, &endp, 0);
|
||||
if (*endp != '\0' && !isspace((unsigned char)*endp)) {
|
||||
fprintf(stderr, "invalid uid '%s' - number "
|
||||
"expected\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
umsk = (int)strtol(optarg, &endp, 0);
|
||||
if (*endp != '\0' && !isspace((unsigned char)*endp)) {
|
||||
fprintf(stderr, "invalid umask '%s' - number "
|
||||
"expected\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1) {
|
||||
fprintf(stderr, "too few arguments\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
if (gids != NULL) {
|
||||
fprintf(stderr, "changing groups to %s\n", gids);
|
||||
set_gids(gids);
|
||||
}
|
||||
if (uid != -1) {
|
||||
fprintf(stderr, "changing uid to %d\n", uid);
|
||||
if (setuid(uid) < 0) {
|
||||
fprintf(stderr, "cannot change uid: %s\n",
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Change umask to requested value or to 0, if not requested. */
|
||||
umask(umsk);
|
||||
|
||||
for (;;) {
|
||||
scall = find_syscall(argv[0]);
|
||||
if (scall == NULL) {
|
||||
fprintf(stderr, "syscall '%s' not supported\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
argc++;
|
||||
argv++;
|
||||
n = call_syscall(scall, argv);
|
||||
argc += n;
|
||||
argv += n;
|
||||
if (argv[0] == NULL)
|
||||
break;
|
||||
argc++;
|
||||
argv++;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
err2str(int error)
|
||||
{
|
||||
static char errnum[8];
|
||||
|
||||
switch (error) {
|
||||
#ifdef EPERM
|
||||
case EPERM:
|
||||
return ("EPERM");
|
||||
#endif
|
||||
#ifdef ENOENT
|
||||
case ENOENT:
|
||||
return ("ENOENT");
|
||||
#endif
|
||||
#ifdef ESRCH
|
||||
case ESRCH:
|
||||
return ("ESRCH");
|
||||
#endif
|
||||
#ifdef EINTR
|
||||
case EINTR:
|
||||
return ("EINTR");
|
||||
#endif
|
||||
#ifdef EIO
|
||||
case EIO:
|
||||
return ("EIO");
|
||||
#endif
|
||||
#ifdef ENXIO
|
||||
case ENXIO:
|
||||
return ("ENXIO");
|
||||
#endif
|
||||
#ifdef E2BIG
|
||||
case E2BIG:
|
||||
return ("E2BIG");
|
||||
#endif
|
||||
#ifdef ENOEXEC
|
||||
case ENOEXEC:
|
||||
return ("ENOEXEC");
|
||||
#endif
|
||||
#ifdef EBADF
|
||||
case EBADF:
|
||||
return ("EBADF");
|
||||
#endif
|
||||
#ifdef ECHILD
|
||||
case ECHILD:
|
||||
return ("ECHILD");
|
||||
#endif
|
||||
#ifdef EDEADLK
|
||||
case EDEADLK:
|
||||
return ("EDEADLK");
|
||||
#endif
|
||||
#ifdef ENOMEM
|
||||
case ENOMEM:
|
||||
return ("ENOMEM");
|
||||
#endif
|
||||
#ifdef EACCES
|
||||
case EACCES:
|
||||
return ("EACCES");
|
||||
#endif
|
||||
#ifdef EFAULT
|
||||
case EFAULT:
|
||||
return ("EFAULT");
|
||||
#endif
|
||||
#ifdef ENOTBLK
|
||||
case ENOTBLK:
|
||||
return ("ENOTBLK");
|
||||
#endif
|
||||
#ifdef EBUSY
|
||||
case EBUSY:
|
||||
return ("EBUSY");
|
||||
#endif
|
||||
#ifdef EEXIST
|
||||
case EEXIST:
|
||||
return ("EEXIST");
|
||||
#endif
|
||||
#ifdef EXDEV
|
||||
case EXDEV:
|
||||
return ("EXDEV");
|
||||
#endif
|
||||
#ifdef ENODEV
|
||||
case ENODEV:
|
||||
return ("ENODEV");
|
||||
#endif
|
||||
#ifdef ENOTDIR
|
||||
case ENOTDIR:
|
||||
return ("ENOTDIR");
|
||||
#endif
|
||||
#ifdef EISDIR
|
||||
case EISDIR:
|
||||
return ("EISDIR");
|
||||
#endif
|
||||
#ifdef EINVAL
|
||||
case EINVAL:
|
||||
return ("EINVAL");
|
||||
#endif
|
||||
#ifdef ENFILE
|
||||
case ENFILE:
|
||||
return ("ENFILE");
|
||||
#endif
|
||||
#ifdef EMFILE
|
||||
case EMFILE:
|
||||
return ("EMFILE");
|
||||
#endif
|
||||
#ifdef ENOTTY
|
||||
case ENOTTY:
|
||||
return ("ENOTTY");
|
||||
#endif
|
||||
#ifdef ETXTBSY
|
||||
case ETXTBSY:
|
||||
return ("ETXTBSY");
|
||||
#endif
|
||||
#ifdef EFBIG
|
||||
case EFBIG:
|
||||
return ("EFBIG");
|
||||
#endif
|
||||
#ifdef ENOSPC
|
||||
case ENOSPC:
|
||||
return ("ENOSPC");
|
||||
#endif
|
||||
#ifdef ESPIPE
|
||||
case ESPIPE:
|
||||
return ("ESPIPE");
|
||||
#endif
|
||||
#ifdef EROFS
|
||||
case EROFS:
|
||||
return ("EROFS");
|
||||
#endif
|
||||
#ifdef EMLINK
|
||||
case EMLINK:
|
||||
return ("EMLINK");
|
||||
#endif
|
||||
#ifdef EPIPE
|
||||
case EPIPE:
|
||||
return ("EPIPE");
|
||||
#endif
|
||||
#ifdef EDOM
|
||||
case EDOM:
|
||||
return ("EDOM");
|
||||
#endif
|
||||
#ifdef ERANGE
|
||||
case ERANGE:
|
||||
return ("ERANGE");
|
||||
#endif
|
||||
#ifdef EAGAIN
|
||||
case EAGAIN:
|
||||
return ("EAGAIN");
|
||||
#endif
|
||||
#ifdef EINPROGRESS
|
||||
case EINPROGRESS:
|
||||
return ("EINPROGRESS");
|
||||
#endif
|
||||
#ifdef EALREADY
|
||||
case EALREADY:
|
||||
return ("EALREADY");
|
||||
#endif
|
||||
#ifdef ENOTSOCK
|
||||
case ENOTSOCK:
|
||||
return ("ENOTSOCK");
|
||||
#endif
|
||||
#ifdef EDESTADDRREQ
|
||||
case EDESTADDRREQ:
|
||||
return ("EDESTADDRREQ");
|
||||
#endif
|
||||
#ifdef EMSGSIZE
|
||||
case EMSGSIZE:
|
||||
return ("EMSGSIZE");
|
||||
#endif
|
||||
#ifdef EPROTOTYPE
|
||||
case EPROTOTYPE:
|
||||
return ("EPROTOTYPE");
|
||||
#endif
|
||||
#ifdef ENOPROTOOPT
|
||||
case ENOPROTOOPT:
|
||||
return ("ENOPROTOOPT");
|
||||
#endif
|
||||
#ifdef EPROTONOSUPPORT
|
||||
case EPROTONOSUPPORT:
|
||||
return ("EPROTONOSUPPORT");
|
||||
#endif
|
||||
#ifdef ESOCKTNOSUPPORT
|
||||
case ESOCKTNOSUPPORT:
|
||||
return ("ESOCKTNOSUPPORT");
|
||||
#endif
|
||||
#ifdef EOPNOTSUPP
|
||||
case EOPNOTSUPP:
|
||||
return ("EOPNOTSUPP");
|
||||
#endif
|
||||
#ifdef EPFNOSUPPORT
|
||||
case EPFNOSUPPORT:
|
||||
return ("EPFNOSUPPORT");
|
||||
#endif
|
||||
#ifdef EAFNOSUPPORT
|
||||
case EAFNOSUPPORT:
|
||||
return ("EAFNOSUPPORT");
|
||||
#endif
|
||||
#ifdef EADDRINUSE
|
||||
case EADDRINUSE:
|
||||
return ("EADDRINUSE");
|
||||
#endif
|
||||
#ifdef EADDRNOTAVAIL
|
||||
case EADDRNOTAVAIL:
|
||||
return ("EADDRNOTAVAIL");
|
||||
#endif
|
||||
#ifdef ENETDOWN
|
||||
case ENETDOWN:
|
||||
return ("ENETDOWN");
|
||||
#endif
|
||||
#ifdef ENETUNREACH
|
||||
case ENETUNREACH:
|
||||
return ("ENETUNREACH");
|
||||
#endif
|
||||
#ifdef ENETRESET
|
||||
case ENETRESET:
|
||||
return ("ENETRESET");
|
||||
#endif
|
||||
#ifdef ECONNABORTED
|
||||
case ECONNABORTED:
|
||||
return ("ECONNABORTED");
|
||||
#endif
|
||||
#ifdef ECONNRESET
|
||||
case ECONNRESET:
|
||||
return ("ECONNRESET");
|
||||
#endif
|
||||
#ifdef ENOBUFS
|
||||
case ENOBUFS:
|
||||
return ("ENOBUFS");
|
||||
#endif
|
||||
#ifdef EISCONN
|
||||
case EISCONN:
|
||||
return ("EISCONN");
|
||||
#endif
|
||||
#ifdef ENOTCONN
|
||||
case ENOTCONN:
|
||||
return ("ENOTCONN");
|
||||
#endif
|
||||
#ifdef ESHUTDOWN
|
||||
case ESHUTDOWN:
|
||||
return ("ESHUTDOWN");
|
||||
#endif
|
||||
#ifdef ETOOMANYREFS
|
||||
case ETOOMANYREFS:
|
||||
return ("ETOOMANYREFS");
|
||||
#endif
|
||||
#ifdef ETIMEDOUT
|
||||
case ETIMEDOUT:
|
||||
return ("ETIMEDOUT");
|
||||
#endif
|
||||
#ifdef ECONNREFUSED
|
||||
case ECONNREFUSED:
|
||||
return ("ECONNREFUSED");
|
||||
#endif
|
||||
#ifdef ELOOP
|
||||
case ELOOP:
|
||||
return ("ELOOP");
|
||||
#endif
|
||||
#ifdef ENAMETOOLONG
|
||||
case ENAMETOOLONG:
|
||||
return ("ENAMETOOLONG");
|
||||
#endif
|
||||
#ifdef EHOSTDOWN
|
||||
case EHOSTDOWN:
|
||||
return ("EHOSTDOWN");
|
||||
#endif
|
||||
#ifdef EHOSTUNREACH
|
||||
case EHOSTUNREACH:
|
||||
return ("EHOSTUNREACH");
|
||||
#endif
|
||||
#ifdef ENOTEMPTY
|
||||
case ENOTEMPTY:
|
||||
return ("ENOTEMPTY");
|
||||
#endif
|
||||
#ifdef EPROCLIM
|
||||
case EPROCLIM:
|
||||
return ("EPROCLIM");
|
||||
#endif
|
||||
#ifdef EUSERS
|
||||
case EUSERS:
|
||||
return ("EUSERS");
|
||||
#endif
|
||||
#ifdef EDQUOT
|
||||
case EDQUOT:
|
||||
return ("EDQUOT");
|
||||
#endif
|
||||
#ifdef ESTALE
|
||||
case ESTALE:
|
||||
return ("ESTALE");
|
||||
#endif
|
||||
#ifdef EREMOTE
|
||||
case EREMOTE:
|
||||
return ("EREMOTE");
|
||||
#endif
|
||||
#ifdef EBADRPC
|
||||
case EBADRPC:
|
||||
return ("EBADRPC");
|
||||
#endif
|
||||
#ifdef ERPCMISMATCH
|
||||
case ERPCMISMATCH:
|
||||
return ("ERPCMISMATCH");
|
||||
#endif
|
||||
#ifdef EPROGUNAVAIL
|
||||
case EPROGUNAVAIL:
|
||||
return ("EPROGUNAVAIL");
|
||||
#endif
|
||||
#ifdef EPROGMISMATCH
|
||||
case EPROGMISMATCH:
|
||||
return ("EPROGMISMATCH");
|
||||
#endif
|
||||
#ifdef EPROCUNAVAIL
|
||||
case EPROCUNAVAIL:
|
||||
return ("EPROCUNAVAIL");
|
||||
#endif
|
||||
#ifdef ENOLCK
|
||||
case ENOLCK:
|
||||
return ("ENOLCK");
|
||||
#endif
|
||||
#ifdef ENOSYS
|
||||
case ENOSYS:
|
||||
return ("ENOSYS");
|
||||
#endif
|
||||
#ifdef EFTYPE
|
||||
case EFTYPE:
|
||||
return ("EFTYPE");
|
||||
#endif
|
||||
#ifdef EAUTH
|
||||
case EAUTH:
|
||||
return ("EAUTH");
|
||||
#endif
|
||||
#ifdef ENEEDAUTH
|
||||
case ENEEDAUTH:
|
||||
return ("ENEEDAUTH");
|
||||
#endif
|
||||
#ifdef EIDRM
|
||||
case EIDRM:
|
||||
return ("EIDRM");
|
||||
#endif
|
||||
#ifdef ENOMSG
|
||||
case ENOMSG:
|
||||
return ("ENOMSG");
|
||||
#endif
|
||||
#ifdef EOVERFLOW
|
||||
case EOVERFLOW:
|
||||
return ("EOVERFLOW");
|
||||
#endif
|
||||
#ifdef ECANCELED
|
||||
case ECANCELED:
|
||||
return ("ECANCELED");
|
||||
#endif
|
||||
#ifdef EILSEQ
|
||||
case EILSEQ:
|
||||
return ("EILSEQ");
|
||||
#endif
|
||||
#ifdef ENOATTR
|
||||
case ENOATTR:
|
||||
return ("ENOATTR");
|
||||
#endif
|
||||
#ifdef EDOOFUS
|
||||
case EDOOFUS:
|
||||
return ("EDOOFUS");
|
||||
#endif
|
||||
#ifdef EBADMSG
|
||||
case EBADMSG:
|
||||
return ("EBADMSG");
|
||||
#endif
|
||||
#ifdef EMULTIHOP
|
||||
case EMULTIHOP:
|
||||
return ("EMULTIHOP");
|
||||
#endif
|
||||
#ifdef ENOLINK
|
||||
case ENOLINK:
|
||||
return ("ENOLINK");
|
||||
#endif
|
||||
#ifdef EPROTO
|
||||
case EPROTO:
|
||||
return ("EPROTO");
|
||||
#endif
|
||||
default:
|
||||
snprintf(errnum, sizeof(errnum), "%d", error);
|
||||
return (errnum);
|
||||
}
|
||||
}
|
178
tools/regression/fstest/tests/chflags/00.t
Normal file
178
tools/regression/fstest/tests/chflags/00.t
Normal file
@ -0,0 +1,178 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags changes flags"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..191"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n2} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n2}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect none stat ${n0} flags
|
||||
expect 0 chflags ${n0} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n0} flags
|
||||
expect 0 chflags ${n0} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE stat ${n0} flags
|
||||
expect 0 chflags ${n0} SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n0} flags
|
||||
expect 0 chflags ${n0} none
|
||||
expect none stat ${n0} flags
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkdir ${n0} 0644
|
||||
expect none stat ${n0} flags
|
||||
expect 0 chflags ${n0} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n0} flags
|
||||
expect 0 chflags ${n0} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE stat ${n0} flags
|
||||
expect 0 chflags ${n0} SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n0} flags
|
||||
expect 0 chflags ${n0} none
|
||||
expect none stat ${n0} flags
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect none stat ${n0} flags
|
||||
expect 0 chflags ${n0} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n0} flags
|
||||
expect 0 chflags ${n0} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE stat ${n0} flags
|
||||
expect 0 chflags ${n0} SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n0} flags
|
||||
expect 0 chflags ${n0} none
|
||||
expect none stat ${n0} flags
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect none stat ${n1} flags
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 chflags ${n1} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n1} flags
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 chflags ${n1} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE stat ${n1} flags
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 chflags ${n1} SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK stat ${n1} flags
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 chflags ${n1} none
|
||||
expect none stat ${n1} flags
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect none stat ${n1} flags
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 lchflags ${n1} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK lstat ${n1} flags
|
||||
expect none stat ${n1} flags
|
||||
expect 0 lchflags ${n1} UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE
|
||||
expect UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE lstat ${n1} flags
|
||||
expect none stat ${n1} flags
|
||||
expect 0 lchflags ${n1} SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK
|
||||
expect SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK lstat ${n1} flags
|
||||
expect none stat ${n1} flags
|
||||
expect 0 lchflags ${n1} none
|
||||
expect none lstat ${n1} flags
|
||||
expect none stat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# successful chflags(2) updates ctime.
|
||||
expect 0 create ${n0} 0644
|
||||
for flag in UF_NODUMP UF_IMMUTABLE UF_APPEND UF_NOUNLINK UF_OPAQUE SF_ARCHIVED SF_IMMUTABLE SF_APPEND SF_NOUNLINK none; do
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chflags ${n0} ${flag}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
done
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
for flag in UF_NODUMP UF_IMMUTABLE UF_APPEND UF_NOUNLINK UF_OPAQUE SF_ARCHIVED SF_IMMUTABLE SF_APPEND SF_NOUNLINK none; do
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chflags ${n0} ${flag}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
done
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
for flag in UF_NODUMP UF_IMMUTABLE UF_APPEND UF_NOUNLINK UF_OPAQUE SF_ARCHIVED SF_IMMUTABLE SF_APPEND SF_NOUNLINK none; do
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chflags ${n0} ${flag}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
done
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
for flag in UF_NODUMP UF_IMMUTABLE UF_APPEND UF_NOUNLINK UF_OPAQUE SF_ARCHIVED SF_IMMUTABLE SF_APPEND SF_NOUNLINK none; do
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 lchflags ${n0} ${flag}
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
done
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# unsuccessful chflags(2) does not update ctime.
|
||||
expect 0 create ${n0} 0644
|
||||
for flag in UF_IMMUTABLE SF_IMMUTABLE none; do
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chflags ${n0} ${flag}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
done
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
for flag in UF_IMMUTABLE SF_IMMUTABLE none; do
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chflags ${n0} ${flag}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
done
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
for flag in UF_IMMUTABLE SF_IMMUTABLE none; do
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chflags ${n0} ${flag}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
done
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
for flag in UF_IMMUTABLE SF_IMMUTABLE none; do
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 lchflags ${n0} ${flag}
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
done
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n2}
|
20
tools/regression/fstest/tests/chflags/01.t
Normal file
20
tools/regression/fstest/tests/chflags/01.t
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns ENOTDIR if a component of the path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR chflags ${n0}/${n1}/test UF_IMMUTABLE
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
18
tools/regression/fstest/tests/chflags/02.t
Normal file
18
tools/regression/fstest/tests/chflags/02.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..6"
|
||||
|
||||
expect 0 create ${name255} 0644
|
||||
expect 0 chflags ${name255} UF_IMMUTABLE
|
||||
expect UF_IMMUTABLE stat ${name255} flags
|
||||
expect 0 chflags ${name255} none
|
||||
expect 0 unlink ${name255}
|
||||
expect ENAMETOOLONG chflags ${name256} UF_IMMUTABLE
|
25
tools/regression/fstest/tests/chflags/03.t
Normal file
25
tools/regression/fstest/tests/chflags/03.t
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..13"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 create ${path1023} 0644
|
||||
expect 0 chflags ${path1023} UF_IMMUTABLE
|
||||
expect 0 chflags ${path1023} none
|
||||
expect 0 unlink ${path1023}
|
||||
expect ENAMETOOLONG chflags ${path1024} UF_IMMUTABLE
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
19
tools/regression/fstest/tests/chflags/04.t
Normal file
19
tools/regression/fstest/tests/chflags/04.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns ENOENT if the named file does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..4"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT chflags ${n0}/${n1}/test UF_IMMUTABLE
|
||||
expect ENOENT chflags ${n0}/${n1} UF_IMMUTABLE
|
||||
expect 0 rmdir ${n0}
|
35
tools/regression/fstest/tests/chflags/05.t
Normal file
35
tools/regression/fstest/tests/chflags/05.t
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EACCES when search permission is denied for a component of the path prefix"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..16"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_IMMUTABLE
|
||||
expect UF_IMMUTABLE -u 65534 -g 65534 stat ${n1}/${n2} flags
|
||||
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65534 chflags ${n1}/${n2} UF_IMMUTABLE
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_IMMUTABLE
|
||||
expect UF_IMMUTABLE -u 65534 -g 65534 stat ${n1}/${n2} flags
|
||||
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
21
tools/regression/fstest/tests/chflags/06.t
Normal file
21
tools/regression/fstest/tests/chflags/06.t
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns ELOOP if too many symbolic links were encountered in translating the pathname"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP chflags ${n0}/test UF_IMMUTABLE
|
||||
expect ELOOP chflags ${n1}/test UF_IMMUTABLE
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
54
tools/regression/fstest/tests/chflags/07.t
Normal file
54
tools/regression/fstest/tests/chflags/07.t
Normal file
@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..30"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect none stat ${n1} flags
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect none stat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect none stat ${n1} flags
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect none stat ${n1} flags
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 mkfifo ${n1} 0644
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect none stat ${n1} flags
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect none stat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 symlink ${n2} ${n1}
|
||||
expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_IMMUTABLE
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 lchown ${n1} 65534 65534
|
||||
expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_IMMUTABLE
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
70
tools/regression/fstest/tests/chflags/08.t
Normal file
70
tools/regression/fstest/tests/chflags/08.t
Normal file
@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..78"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 chflags ${n1} ${flag}
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
done
|
||||
expect 0 chflags ${n1} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 chflags ${n1} ${flag}
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
done
|
||||
expect 0 chflags ${n1} none
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 mkfifo ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 chflags ${n1} ${flag}
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
done
|
||||
expect 0 chflags ${n1} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 symlink ${n2} ${n1}
|
||||
expect 0 lchown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 lchflags ${n1} ${flag}
|
||||
expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} lstat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} lstat ${n1} flags
|
||||
done
|
||||
expect 0 lchflags ${n1} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
82
tools/regression/fstest/tests/chflags/09.t
Normal file
82
tools/regression/fstest/tests/chflags/09.t
Normal file
@ -0,0 +1,82 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and securelevel is greater than 0"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..102"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
old=`sysctl -n security.jail.chflags_allowed`
|
||||
sysctl security.jail.chflags_allowed=1 >/dev/null
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 chflags ${n1} ${flag}
|
||||
jexpect 1 `pwd` EPERM chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
done
|
||||
expect 0 chflags ${n1} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 chflags ${n1} ${flag}
|
||||
jexpect 1 `pwd` EPERM chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
done
|
||||
expect 0 chflags ${n1} none
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 mkfifo ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 chflags ${n1} ${flag}
|
||||
jexpect 1 `pwd` EPERM chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} stat ${n1} flags
|
||||
done
|
||||
expect 0 chflags ${n1} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 symlink ${n2} ${n1}
|
||||
expect 0 lchown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect 0 lchflags ${n1} ${flag}
|
||||
jexpect 1 `pwd` EPERM lchflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} lstat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65533 -g 65533 lchflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} lstat ${n1} flags
|
||||
jexpect 1 `pwd` EPERM -u 65534 -g 65534 lchflags ${n1} UF_IMMUTABLE
|
||||
expect ${flag} lstat ${n1} flags
|
||||
done
|
||||
expect 0 lchflags ${n1} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
sysctl security.jail.chflags_allowed=${old} >/dev/null
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
62
tools/regression/fstest/tests/chflags/10.t
Normal file
62
tools/regression/fstest/tests/chflags/10.t
Normal file
@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..62"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag}
|
||||
expect none stat ${n1} flags
|
||||
done
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag}
|
||||
expect none stat ${n1} flags
|
||||
done
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 mkfifo ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag}
|
||||
expect none stat ${n1} flags
|
||||
done
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 symlink ${n2} ${n1}
|
||||
expect 0 lchown ${n1} 65534 65534
|
||||
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
|
||||
expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag}
|
||||
expect none lstat ${n1} flags
|
||||
expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag}
|
||||
expect none lstat ${n1} flags
|
||||
done
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
70
tools/regression/fstest/tests/chflags/11.t
Normal file
70
tools/regression/fstest/tests/chflags/11.t
Normal file
@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EPERM if a user tries to set or remove the SF_SNAPSHOT flag"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..46"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0644
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 mkfifo ${n1} 0644
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect EPERM chflags ${n1} SF_SNAPSHOT
|
||||
expect none stat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 symlink ${n2} ${n1}
|
||||
expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
|
||||
expect none lstat ${n1} flags
|
||||
expect EPERM lchflags ${n1} SF_SNAPSHOT
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 lchown ${n1} 65534 65534
|
||||
expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
|
||||
expect none lstat ${n1} flags
|
||||
expect EPERM lchflags ${n1} SF_SNAPSHOT
|
||||
expect none lstat ${n1} flags
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
43
tools/regression/fstest/tests/chflags/12.t
Normal file
43
tools/regression/fstest/tests/chflags/12.t
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EROFS if the named file resides on a read-only file system"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..14"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
|
||||
expect UF_IMMUTABLE stat ${n0}/${n1} flags
|
||||
expect 0 chflags ${n0}/${n1} none
|
||||
expect none stat ${n0}/${n1} flags
|
||||
mount -ur /dev/md${n}
|
||||
expect EROFS chflags ${n0}/${n1} UF_IMMUTABLE
|
||||
expect none stat ${n0}/${n1} flags
|
||||
mount -uw /dev/md${n}
|
||||
expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
|
||||
expect UF_IMMUTABLE stat ${n0}/${n1} flags
|
||||
expect 0 chflags ${n0}/${n1} none
|
||||
expect none stat ${n0}/${n1} flags
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
14
tools/regression/fstest/tests/chflags/13.t
Normal file
14
tools/regression/fstest/tests/chflags/13.t
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chflags returns EFAULT if the path argument points outside the process's allocated address space"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..2"
|
||||
|
||||
expect EFAULT chflags NULL UF_IMMUTABLE
|
||||
expect EFAULT chflags DEADCODE UF_IMMUTABLE
|
161
tools/regression/fstest/tests/chmod/00.t
Normal file
161
tools/regression/fstest/tests/chmod/00.t
Normal file
@ -0,0 +1,161 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod changes permission"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
if supported lchmod; then
|
||||
echo "1..77"
|
||||
else
|
||||
echo "1..58"
|
||||
fi
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n2} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n2}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0 chmod ${n0} 0111
|
||||
expect 0111 stat ${n0} mode
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0755 stat ${n0} mode
|
||||
expect 0 chmod ${n0} 0753
|
||||
expect 0753 stat ${n0} mode
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0 chmod ${n0} 0310
|
||||
expect 0310 stat ${n0} mode
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0644 stat ${n1} mode
|
||||
expect 0 chmod ${n1} 0321
|
||||
expect 0321 stat ${n1} mode
|
||||
expect 0321 lstat ${n0} mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
if supported lchmod; then
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0644 stat ${n1} mode
|
||||
expect 0 lchmod ${n1} 0321
|
||||
expect 0321 lstat ${n1} mode
|
||||
expect 0 lchmod ${n1} 0531
|
||||
expect 0531 lstat ${n1} mode
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0644 stat ${n1} mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
fi
|
||||
|
||||
# successful chmod(2) updates ctime.
|
||||
expect 0 create ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chmod ${n0} 0111
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chmod ${n0} 0753
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chmod ${n0} 0310
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
if supported lchmod; then
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 lchmod ${n0} 0321
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
fi
|
||||
|
||||
# unsuccessful chmod(2) does not update ctime.
|
||||
expect 0 create ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chmod ${n0} 0111
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chmod ${n0} 0753
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chmod ${n0} 0310
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
if supported lchmod; then
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 lchmod ${n0} 0321
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
fi
|
||||
|
||||
# POSIX: If the calling process does not have appropriate privileges, and if
|
||||
# the group ID of the file does not match the effective group ID or one of the
|
||||
# supplementary group IDs and if the file is a regular file, bit S_ISGID
|
||||
# (set-group-ID on execution) in the file's mode shall be cleared upon
|
||||
# successful return from chmod().
|
||||
|
||||
expect 0 create ${n0} 0755
|
||||
expect 0 chown ${n0} 65535 65535
|
||||
expect 0 -u 65535 -g 65535 chmod ${n0} 02755
|
||||
expect 02755 stat ${n0} mode
|
||||
expect 0 -u 65535 -g 65535 chmod ${n0} 0755
|
||||
expect 0755 stat ${n0} mode
|
||||
|
||||
# Unfortunately FreeBSD doesn't clear set-gid bit, but returns EPERM instead.
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
expect EPERM -u 65535 -g 65534 chmod ${n0} 02755
|
||||
expect 0755 stat ${n0} mode
|
||||
;;
|
||||
*)
|
||||
expect 0 -u 65535 -g 65534 chmod ${n0} 02755
|
||||
expect 0755 stat ${n0} mode
|
||||
;;
|
||||
esac
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n2}
|
18
tools/regression/fstest/tests/chmod/01.t
Normal file
18
tools/regression/fstest/tests/chmod/01.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns ENOTDIR if a component of the path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR chmod ${n0}/${n1}/test 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
15
tools/regression/fstest/tests/chmod/02.t
Normal file
15
tools/regression/fstest/tests/chmod/02.t
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
expect 0 create ${name255} 0644
|
||||
expect 0 chmod ${name255} 0620
|
||||
expect 0620 stat ${name255} mode
|
||||
expect 0 unlink ${name255}
|
||||
expect ENAMETOOLONG chmod ${name256} 0620
|
22
tools/regression/fstest/tests/chmod/03.t
Normal file
22
tools/regression/fstest/tests/chmod/03.t
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 create ${path1023} 0644
|
||||
expect 0 chmod ${path1023} 0642
|
||||
expect 0 unlink ${path1023}
|
||||
expect ENAMETOOLONG chmod ${path1024} 0642
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
17
tools/regression/fstest/tests/chmod/04.t
Normal file
17
tools/regression/fstest/tests/chmod/04.t
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns ENOENT if the named file does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..4"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT chmod ${n0}/${n1}/test 0644
|
||||
expect ENOENT chmod ${n0}/${n1} 0644
|
||||
expect 0 rmdir ${n0}
|
31
tools/regression/fstest/tests/chmod/05.t
Normal file
31
tools/regression/fstest/tests/chmod/05.t
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns EACCES when search permission is denied for a component of the path prefix"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..14"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
|
||||
expect 0642 -u 65534 -g 65534 stat ${n1}/${n2} mode
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65534 chmod ${n1}/${n2} 0620
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0420
|
||||
expect 0420 -u 65534 -g 65534 stat ${n1}/${n2} mode
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
19
tools/regression/fstest/tests/chmod/06.t
Normal file
19
tools/regression/fstest/tests/chmod/06.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns ELOOP if too many symbolic links were encountered in translating the pathname"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP chmod ${n0}/test 0644
|
||||
expect ELOOP chmod ${n1}/test 0644
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
31
tools/regression/fstest/tests/chmod/07.t
Normal file
31
tools/regression/fstest/tests/chmod/07.t
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..14"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
|
||||
expect 0642 stat ${n1}/${n2} mode
|
||||
expect EPERM -u 65533 -g 65533 chmod ${n1}/${n2} 0641
|
||||
expect 0642 stat ${n1}/${n2} mode
|
||||
expect 0 chown ${n1}/${n2} 0 0
|
||||
expect EPERM -u 65534 -g 65534 chmod ${n1}/${n2} 0641
|
||||
expect 0642 stat ${n1}/${n2} mode
|
||||
expect 0 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
59
tools/regression/fstest/tests/chmod/08.t
Normal file
59
tools/regression/fstest/tests/chmod/08.t
Normal file
@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns EPERM if the named file has its immutable or append-only flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..40"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM chmod ${n0} 0600
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chmod ${n0} 0600
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM chmod ${n0} 0600
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chmod ${n0} 0600
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect EPERM chmod ${n0} 0600
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chmod ${n0} 0600
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect EPERM chmod ${n0} 0600
|
||||
expect 0644 stat ${n0} mode
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chmod ${n0} 0600
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 chmod ${n0} 0600
|
||||
expect 0600 stat ${n0} mode
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 chmod ${n0} 0600
|
||||
expect 0600 stat ${n0} mode
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
37
tools/regression/fstest/tests/chmod/09.t
Normal file
37
tools/regression/fstest/tests/chmod/09.t
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns EROFS if the named file resides on a read-only file system"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..10"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect 0 chmod ${n0}/${n1} 0640
|
||||
expect 0640 stat ${n0}/${n1} mode
|
||||
mount -ur /dev/md${n}
|
||||
expect EROFS chmod ${n0}/${n1} 0600
|
||||
expect 0640 stat ${n0}/${n1} mode
|
||||
mount -uw /dev/md${n}
|
||||
expect 0 chmod ${n0}/${n1} 0600
|
||||
expect 0600 stat ${n0}/${n1} mode
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
12
tools/regression/fstest/tests/chmod/10.t
Normal file
12
tools/regression/fstest/tests/chmod/10.t
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns EFAULT if the path argument points outside the process's allocated address space"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..2"
|
||||
|
||||
expect EFAULT chmod NULL 0644
|
||||
expect EFAULT chmod DEADCODE 0644
|
53
tools/regression/fstest/tests/chmod/11.t
Normal file
53
tools/regression/fstest/tests/chmod/11.t
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chmod returns EFTYPE if the effective user ID is not the super-user, the mode includes the sticky bit (S_ISVTX), and path does not refer to a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..20"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chmod ${n1} 01755
|
||||
expect 01755 stat ${n1} mode
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect 0 chmod ${n1} 01644
|
||||
expect 01644 stat ${n1} mode
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 01755
|
||||
expect 01755 stat ${n1} mode
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
case "${os}" in
|
||||
FreeBSD)
|
||||
expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644
|
||||
expect 0644 stat ${n1} mode
|
||||
;;
|
||||
SunOS)
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 01644
|
||||
expect 0644 stat ${n1} mode
|
||||
;;
|
||||
Linux)
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 01644
|
||||
expect 01644 stat ${n1} mode
|
||||
;;
|
||||
esac
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
304
tools/regression/fstest/tests/chown/00.t
Normal file
304
tools/regression/fstest/tests/chown/00.t
Normal file
@ -0,0 +1,304 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown changes ownership"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
if supported lchmod; then
|
||||
echo "1..186"
|
||||
else
|
||||
echo "1..171"
|
||||
fi
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n2} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n2}
|
||||
|
||||
# super-user can always modify ownership
|
||||
# 2
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 123 456
|
||||
expect 123,456 lstat ${n0} uid,gid
|
||||
expect 0 chown ${n0} 0 0
|
||||
expect 0,0 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
# 8
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect 0 chown ${n0} 123 456
|
||||
expect 123,456 lstat ${n0} uid,gid
|
||||
expect 0 chown ${n0} 0 0
|
||||
expect 0,0 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
# 14
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 chown ${n0} 123 456
|
||||
expect 123,456 lstat ${n0} uid,gid
|
||||
expect 0 chown ${n0} 0 0
|
||||
expect 0,0 lstat ${n0} uid,gid
|
||||
expect 0 rmdir ${n0}
|
||||
# 20
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 chown ${n1} 123 456
|
||||
expect 123,456 stat ${n1} uid,gid
|
||||
expect 123,456 stat ${n0} uid,gid
|
||||
expect 0 lchown ${n1} 135 579
|
||||
expect 135,579 lstat ${n1} uid,gid
|
||||
expect 123,456 stat ${n1} uid,gid
|
||||
expect 123,456 stat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
# non-super-user can modify file group if he is owner of a file and
|
||||
# gid he is setting is in his groups list.
|
||||
# 31
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 65534,65533 lstat ${n0} uid,gid
|
||||
expect 0 -u 65534 -g 65532,65531 chown ${n0} -1 65532
|
||||
expect 65534,65532 lstat ${n0} uid,gid
|
||||
expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531
|
||||
expect 65534,65531 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# chown(2) return 0 if user is not owner of a file, but chown(2) is called
|
||||
# with both uid and gid equal to -1.
|
||||
# 39
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 0 -u 65532 -g 65531 chown ${n0} -1 -1
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# when super-user calls chown(2), set-uid and set-gid bits are not removed.
|
||||
# 43
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 chown ${n0} 65532 65531
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 unlink ${n0}
|
||||
# 50
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 0 0
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 unlink ${n0}
|
||||
# 57
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 chown ${n0} 0 0
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# when non-super-user calls chown(2) successfully, set-uid and set-gid bits are
|
||||
# removed, except when both uid and gid are equal to -1.
|
||||
# 64
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
|
||||
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533
|
||||
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1
|
||||
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
# 79
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
|
||||
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533
|
||||
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
|
||||
expect 0 chmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1
|
||||
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
|
||||
expect 0 rmdir ${n0}
|
||||
# 94
|
||||
if supported lchmod; then
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect 0 lchown ${n0} 65534 65533
|
||||
expect 0 lchmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 lchown ${n0} 65534 65532
|
||||
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
|
||||
expect 0 lchmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 lchown ${n0} -1 65533
|
||||
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
|
||||
expect 0 lchmod ${n0} 06555
|
||||
expect 06555 lstat ${n0} mode
|
||||
expect 0 -u 65534 -g 65533,65532 lchown ${n0} -1 -1
|
||||
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
fi
|
||||
|
||||
# successfull chown(2) call (except uid and gid equal to -1) updates ctime.
|
||||
# 109
|
||||
expect 0 create ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 65534,65533 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 114
|
||||
expect 0 mkdir ${n0} 0755
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 65534,65533 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 rmdir ${n0}
|
||||
# 119
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 65534,65533 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 124
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 lchown ${n0} 65534 65533
|
||||
expect 65534,65533 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 129
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 -u 65534 -g 65532 chown ${n0} 65534 65532
|
||||
expect 65534,65532 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 135
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 -u 65534 -g 65532 chown ${n0} 65534 65532
|
||||
expect 65534,65532 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 rmdir ${n0}
|
||||
# 141
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} 65534 65533
|
||||
expect 0 -u 65534 -g 65532 chown ${n0} 65534 65532
|
||||
expect 65534,65532 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 148
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect 0 lchown ${n0} 65534 65533
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 -u 65534 -g 65532 lchown ${n0} 65534 65532
|
||||
expect 65534,65532 lstat ${n0} uid,gid
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 154
|
||||
expect 0 create ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} -1 -1
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 158
|
||||
expect 0 mkdir ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} -1 -1
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 rmdir ${n0}
|
||||
# 162
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 chown ${n0} -1 -1
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 166
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 lchown ${n0} -1 -1
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# unsuccessful chown(2) does not update ctime.
|
||||
# 170
|
||||
expect 0 create ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 chown ${n0} 65534 -1
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 174
|
||||
expect 0 mkdir ${n0} 0755
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 -g 65534 chown ${n0} -1 65534
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 rmdir ${n0}
|
||||
# 178
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 -g 65534 chown ${n0} 65534 65534
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
# 182
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
ctime1=`${fstest} lstat ${n0} ctime`
|
||||
sleep 1
|
||||
expect EPERM -u 65534 -g 65534 lchown ${n0} 65534 65534
|
||||
ctime2=`${fstest} lstat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# 186
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n2}
|
18
tools/regression/fstest/tests/chown/01.t
Normal file
18
tools/regression/fstest/tests/chown/01.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns ENOTDIR if a component of the path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR chown ${n0}/${n1}/test 65534 65534
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
15
tools/regression/fstest/tests/chown/02.t
Normal file
15
tools/regression/fstest/tests/chown/02.t
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
expect 0 create ${name255} 0644
|
||||
expect 0 chown ${name255} 65534 65534
|
||||
expect 65534,65534 stat ${name255} uid,gid
|
||||
expect 0 unlink ${name255}
|
||||
expect ENAMETOOLONG chown ${name256} 65533 65533
|
22
tools/regression/fstest/tests/chown/03.t
Normal file
22
tools/regression/fstest/tests/chown/03.t
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 create ${path1023} 0644
|
||||
expect 0 chown ${path1023} 65534 65534
|
||||
expect 0 unlink ${path1023}
|
||||
expect ENAMETOOLONG chown ${path1024} 65533 65533
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
17
tools/regression/fstest/tests/chown/04.t
Normal file
17
tools/regression/fstest/tests/chown/04.t
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns ENOENT if the named file does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..4"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT chown ${n0}/${n1}/test 65534 65534
|
||||
expect ENOENT chown ${n0}/${n1} 65534 65534
|
||||
expect 0 rmdir ${n0}
|
32
tools/regression/fstest/tests/chown/05.t
Normal file
32
tools/regression/fstest/tests/chown/05.t
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns EACCES when search permission is denied for a component of the path prefix"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..15"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65533,65534 chown ${n1}/${n2} -1 65533
|
||||
expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65533,65534 chown ${n1}/${n2} -1 65534
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
|
||||
expect 0 -u 65534 -g 65533,65534 chown ${n1}/${n2} -1 65534
|
||||
expect 65534,65534 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
19
tools/regression/fstest/tests/chown/06.t
Normal file
19
tools/regression/fstest/tests/chown/06.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns ELOOP if too many symbolic links were encountered in translating the pathname"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP chown ${n0}/test 65534 65534
|
||||
expect ELOOP chown ${n1}/test 65534 65534
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
28
tools/regression/fstest/tests/chown/07.t
Normal file
28
tools/regression/fstest/tests/chown/07.t
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user and the process is not an owner of the file"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..11"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
|
||||
expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533
|
||||
expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534
|
||||
expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533
|
||||
expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} -1 65533
|
||||
expect 0 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
53
tools/regression/fstest/tests/chown/08.t
Normal file
53
tools/regression/fstest/tests/chown/08.t
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns EPERM if the named file has its immutable or append-only flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..34"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM chown ${n0} 65534 65534
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM chown ${n0} 65534 65534
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect EPERM chown ${n0} 65534 65534
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect EPERM chown ${n0} 65534 65534
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
37
tools/regression/fstest/tests/chown/09.t
Normal file
37
tools/regression/fstest/tests/chown/09.t
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns EROFS if the named file resides on a read-only file system"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:{fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..10"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect 0 chown ${n0}/${n1} 65534 65534
|
||||
expect 65534,65534 stat ${n0}/${n1} uid,gid
|
||||
mount -ur /dev/md${n}
|
||||
expect EROFS chown ${n0}/${n1} 65533 65533
|
||||
expect 65534,65534 stat ${n0}/${n1} uid,gid
|
||||
mount -uw /dev/md${n}
|
||||
expect 0 chown ${n0}/${n1} 65533 65533
|
||||
expect 65533,65533 stat ${n0}/${n1} uid,gid
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
12
tools/regression/fstest/tests/chown/10.t
Normal file
12
tools/regression/fstest/tests/chown/10.t
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="chown returns EFAULT if the path argument points outside the process's allocated address space"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..2"
|
||||
|
||||
expect EFAULT chown NULL 65534 65534
|
||||
expect EFAULT chown DEADCODE 65534 65534
|
8
tools/regression/fstest/tests/conf
Normal file
8
tools/regression/fstest/tests/conf
Normal file
@ -0,0 +1,8 @@
|
||||
# $FreeBSD$
|
||||
# fstest configuration file
|
||||
|
||||
# Known operating systems: FreeBSD, SunOS, Linux
|
||||
os=`uname`
|
||||
|
||||
# Known file systems: UFS, ZFS, other
|
||||
fs="UFS"
|
151
tools/regression/fstest/tests/link/00.t
Normal file
151
tools/regression/fstest/tests/link/00.t
Normal file
@ -0,0 +1,151 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link creates hardlinks"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..82"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
n3=`namegen`
|
||||
|
||||
expect 0 mkdir ${n3} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n3}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect regular,0644,1 lstat ${n0} type,mode,nlink
|
||||
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect regular,0644,2 lstat ${n0} type,mode,nlink
|
||||
expect regular,0644,2 lstat ${n1} type,mode,nlink
|
||||
|
||||
expect 0 link ${n1} ${n2}
|
||||
expect regular,0644,3 lstat ${n0} type,mode,nlink
|
||||
expect regular,0644,3 lstat ${n1} type,mode,nlink
|
||||
expect regular,0644,3 lstat ${n2} type,mode,nlink
|
||||
|
||||
expect 0 chmod ${n1} 0201
|
||||
expect 0 chown ${n1} 65534 65533
|
||||
|
||||
expect regular,0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect regular,0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect regular,0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 unlink ${n0}
|
||||
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect regular,0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect regular,0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 unlink ${n2}
|
||||
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect regular,0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 unlink ${n1}
|
||||
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect ENOENT lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect fifo,0644,1 lstat ${n0} type,mode,nlink
|
||||
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect fifo,0644,2 lstat ${n0} type,mode,nlink
|
||||
expect fifo,0644,2 lstat ${n1} type,mode,nlink
|
||||
|
||||
expect 0 link ${n1} ${n2}
|
||||
expect fifo,0644,3 lstat ${n0} type,mode,nlink
|
||||
expect fifo,0644,3 lstat ${n1} type,mode,nlink
|
||||
expect fifo,0644,3 lstat ${n2} type,mode,nlink
|
||||
|
||||
expect 0 chmod ${n1} 0201
|
||||
expect 0 chown ${n1} 65534 65533
|
||||
|
||||
expect fifo,0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect fifo,0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect fifo,0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 unlink ${n0}
|
||||
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect fifo,0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect fifo,0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 unlink ${n2}
|
||||
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect fifo,0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
expect 0 unlink ${n1}
|
||||
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
|
||||
expect ENOENT lstat ${n1} type,mode,nlink,uid,gid
|
||||
expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
|
||||
|
||||
# successful link(2) updates ctime.
|
||||
expect 0 create ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
dctime1=`${fstest} stat . ctime`
|
||||
dmtime1=`${fstest} stat . mtime`
|
||||
sleep 1
|
||||
expect 0 link ${n0} ${n1}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
dctime2=`${fstest} stat . ctime`
|
||||
test_check $dctime1 -lt $dctime2
|
||||
dmtime2=`${fstest} stat . mtime`
|
||||
test_check $dctime1 -lt $dmtime2
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
dctime1=`${fstest} stat . ctime`
|
||||
dmtime1=`${fstest} stat . mtime`
|
||||
sleep 1
|
||||
expect 0 link ${n0} ${n1}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
dctime2=`${fstest} stat . ctime`
|
||||
test_check $dctime1 -lt $dctime2
|
||||
dmtime2=`${fstest} stat . mtime`
|
||||
test_check $dctime1 -lt $dmtime2
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
# unsuccessful link(2) does not update ctime.
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 -1
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
dctime1=`${fstest} stat . ctime`
|
||||
dmtime1=`${fstest} stat . mtime`
|
||||
sleep 1
|
||||
expect EACCES -u 65534 link ${n0} ${n1}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
dctime2=`${fstest} stat . ctime`
|
||||
test_check $dctime1 -eq $dctime2
|
||||
dmtime2=`${fstest} stat . mtime`
|
||||
test_check $dctime1 -eq $dmtime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect 0 chown ${n0} 65534 -1
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
dctime1=`${fstest} stat . ctime`
|
||||
dmtime1=`${fstest} stat . mtime`
|
||||
sleep 1
|
||||
expect EACCES -u 65534 link ${n0} ${n1}
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -eq $ctime2
|
||||
dctime2=`${fstest} stat . ctime`
|
||||
test_check $dctime1 -eq $dctime2
|
||||
dmtime2=`${fstest} stat . mtime`
|
||||
test_check $dctime1 -eq $dmtime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n3}
|
22
tools/regression/fstest/tests/link/01.t
Normal file
22
tools/regression/fstest/tests/link/01.t
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ENOTDIR if a component of either path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..8"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR link ${n0}/${n1}/test ${n0}/${n2}
|
||||
expect 0 create ${n0}/${n2} 0644
|
||||
expect ENOTDIR link ${n0}/${n2} ${n0}/${n1}/test
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
expect 0 rmdir ${n0}
|
23
tools/regression/fstest/tests/link/02.t
Normal file
23
tools/regression/fstest/tests/link/02.t
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ENAMETOOLONG if a component of either pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..10"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 create ${name255} 0644
|
||||
expect 0 link ${name255} ${n0}
|
||||
expect 0 unlink ${name255}
|
||||
expect 0 link ${n0} ${name255}
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${name255}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect ENAMETOOLONG link ${n0} ${name256}
|
||||
expect 0 unlink ${n0}
|
||||
expect ENAMETOOLONG link ${name256} ${n0}
|
28
tools/regression/fstest/tests/link/03.t
Normal file
28
tools/regression/fstest/tests/link/03.t
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ENAMETOOLONG if an entire length of either path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..16"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 create ${path1023} 0644
|
||||
expect 0 link ${path1023} ${n0}
|
||||
expect 0 unlink ${path1023}
|
||||
expect 0 link ${n0} ${path1023}
|
||||
expect 0 unlink ${path1023}
|
||||
expect ENAMETOOLONG link ${n0} ${path1024}
|
||||
expect 0 unlink ${n0}
|
||||
expect ENAMETOOLONG link ${path1024} ${n0}
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
20
tools/regression/fstest/tests/link/04.t
Normal file
20
tools/regression/fstest/tests/link/04.t
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ENOENT if a component of either path prefix does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT link ${n0}/${n1}/test ${n2}
|
||||
expect 0 create ${n2} 0644
|
||||
expect ENOENT link ${n2} ${n0}/${n1}/test
|
||||
expect 0 unlink ${n2}
|
||||
expect 0 rmdir ${n0}
|
41
tools/regression/fstest/tests/link/05.t
Normal file
41
tools/regression/fstest/tests/link/05.t
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EMLINK if the link count of the file named by name1 would exceed 32767"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs -i 1 /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
i=1
|
||||
while :; do
|
||||
link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
test_check $i -eq 32767
|
||||
|
||||
expect EMLINK link ${n0}/${n1} ${n0}/${n2}
|
||||
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
43
tools/regression/fstest/tests/link/06.t
Normal file
43
tools/regression/fstest/tests/link/06.t
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EACCES when a component of either path prefix denies search permission"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..18"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
n3=`namegen`
|
||||
n4=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 mkdir ${n2} 0755
|
||||
expect 0 chown ${n2} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644
|
||||
|
||||
expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
|
||||
expect 0 -u 65534 -g 65534 unlink ${n2}/${n4}
|
||||
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4}
|
||||
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
|
||||
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 chmod ${n2} 0644
|
||||
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
|
||||
|
||||
expect 0 unlink ${n1}/${n3}
|
||||
expect 0 rmdir ${n1}
|
||||
expect 0 rmdir ${n2}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
41
tools/regression/fstest/tests/link/07.t
Normal file
41
tools/regression/fstest/tests/link/07.t
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EACCES when the requested link requires writing in a directory with a mode that denies write permission"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..17"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
n3=`namegen`
|
||||
n4=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 mkdir ${n2} 0755
|
||||
expect 0 chown ${n2} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644
|
||||
|
||||
expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
|
||||
expect 0 -u 65534 -g 65534 unlink ${n2}/${n4}
|
||||
|
||||
expect 0 chmod ${n2} 0555
|
||||
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
|
||||
expect 0 chmod ${n1} 0555
|
||||
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4}
|
||||
expect 0 chmod ${n1} 0755
|
||||
|
||||
expect 0 unlink ${n1}/${n3}
|
||||
expect 0 rmdir ${n1}
|
||||
expect 0 rmdir ${n2}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
24
tools/regression/fstest/tests/link/08.t
Normal file
24
tools/regression/fstest/tests/link/08.t
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ELOOP if too many symbolic links were encountered in translating one of the pathnames"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..10"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP link ${n0}/test ${n2}
|
||||
expect ELOOP link ${n1}/test ${n2}
|
||||
expect 0 create ${n2} 0644
|
||||
expect ELOOP link ${n2} ${n0}/test
|
||||
expect ELOOP link ${n2} ${n1}/test
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
expect 0 unlink ${n2}
|
18
tools/regression/fstest/tests/link/09.t
Normal file
18
tools/regression/fstest/tests/link/09.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ENOENT if the source file does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
||||
expect ENOENT link ${n0} ${n1}
|
32
tools/regression/fstest/tests/link/10.t
Normal file
32
tools/regression/fstest/tests/link/10.t
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EEXIST if the destination file does exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..14"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
|
||||
expect 0 create ${n1} 0644
|
||||
expect EEXIST link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect EEXIST link ${n0} ${n1}
|
||||
expect 0 rmdir ${n1}
|
||||
|
||||
expect 0 symlink test ${n1}
|
||||
expect EEXIST link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 mkfifo ${n1} 0644
|
||||
expect EEXIST link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 unlink ${n0}
|
41
tools/regression/fstest/tests/link/11.t
Normal file
41
tools/regression/fstest/tests/link/11.t
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EPERM if the source file is a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
case "${os}:${fs}" in
|
||||
SunOS:UFS)
|
||||
echo "1..10"
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
echo "1..9"
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect EPERM link ${n0} ${n1}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
esac
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 -u 65534 -g 65534 mkdir ${n1} 0755
|
||||
expect EPERM -u 65534 -g 65534 link ${n1} ${n2}
|
||||
expect 0 -u 65534 -g 65534 rmdir ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
55
tools/regression/fstest/tests/link/12.t
Normal file
55
tools/regression/fstest/tests/link/12.t
Normal file
@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EPERM if the source file has its immutable or append-only flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..32"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM link ${n0} ${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM link ${n0} ${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect EPERM link ${n0} ${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect EPERM link ${n0} ${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 link ${n0} ${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n1}
|
||||
|
||||
expect 0 unlink ${n0}
|
56
tools/regression/fstest/tests/link/13.t
Normal file
56
tools/regression/fstest/tests/link/13.t
Normal file
@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EPERM if the parent directory of the destination file has its immutable flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..32"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
34
tools/regression/fstest/tests/link/14.t
Normal file
34
tools/regression/fstest/tests/link/14.t
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EXDEV if the source and the destination files are on different file systems"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}" in
|
||||
FreeBSD)
|
||||
echo "1..8"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect EXDEV link ${n0}/${n1} ${n2}
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 create ${n1} 0644
|
||||
expect EXDEV link ${n1} ${n0}/${n2}
|
||||
expect 0 unlink ${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
38
tools/regression/fstest/tests/link/15.t
Normal file
38
tools/regression/fstest/tests/link/15.t
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns ENOSPC if the directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..4"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 256k`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
i=0
|
||||
while :; do
|
||||
link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
expect ENOSPC link ${n0}/${n1} ${n0}/${n2}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
39
tools/regression/fstest/tests/link/16.t
Normal file
39
tools/regression/fstest/tests/link/16.t
Normal file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EROFS if the requested link requires writing in a directory on a read-only file system"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}" in
|
||||
FreeBSD)
|
||||
echo "1..9"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
mount -ur /dev/md${n}
|
||||
expect EROFS link ${n0}/${n1} ${n0}/${n2}
|
||||
mount -uw /dev/md${n}
|
||||
expect 0 link ${n0}/${n1} ${n0}/${n2}
|
||||
expect 0 unlink ${n0}/${n2}
|
||||
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
20
tools/regression/fstest/tests/link/17.t
Normal file
20
tools/regression/fstest/tests/link/17.t
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="link returns EFAULT if one of the pathnames specified is outside the process's allocated address space"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..8"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect EFAULT link ${n0} NULL
|
||||
expect EFAULT link ${n0} DEADCODE
|
||||
expect 0 unlink ${n0}
|
||||
expect EFAULT link NULL ${n0}
|
||||
expect EFAULT link DEADCODE ${n0}
|
||||
expect EFAULT link NULL DEADCODE
|
||||
expect EFAULT link DEADCODE NULL
|
96
tools/regression/fstest/tests/misc.sh
Normal file
96
tools/regression/fstest/tests/misc.sh
Normal file
@ -0,0 +1,96 @@
|
||||
# $FreeBSD$
|
||||
|
||||
ntest=1
|
||||
|
||||
name253="_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12"
|
||||
name255="${name253}34"
|
||||
name256="${name255}5"
|
||||
path1021="${name255}/${name255}/${name255}/${name253}"
|
||||
path1023="${path1021}/x"
|
||||
path1024="${path1023}x"
|
||||
|
||||
echo ${dir} | egrep '^/' >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
maindir="${dir}/../.."
|
||||
else
|
||||
maindir="`pwd`/${dir}/../.."
|
||||
fi
|
||||
fstest="${maindir}/fstest"
|
||||
. ${maindir}/tests/conf
|
||||
|
||||
expect()
|
||||
{
|
||||
e="${1}"
|
||||
shift
|
||||
r=`${fstest} $* 2>/dev/null | tail -1`
|
||||
echo "${r}" | egrep '^'${e}'$' >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "ok ${ntest}"
|
||||
else
|
||||
echo "not ok ${ntest}"
|
||||
fi
|
||||
ntest=`expr $ntest + 1`
|
||||
}
|
||||
|
||||
jexpect()
|
||||
{
|
||||
s="${1}"
|
||||
d="${2}"
|
||||
e="${3}"
|
||||
shift 3
|
||||
r=`jail -s ${s} / fstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 2>/dev/null" | tail -1`
|
||||
echo "${r}" | egrep '^'${e}'$' >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "ok ${ntest}"
|
||||
else
|
||||
echo "not ok ${ntest}"
|
||||
fi
|
||||
ntest=`expr $ntest + 1`
|
||||
}
|
||||
|
||||
test_check()
|
||||
{
|
||||
if [ $* ]; then
|
||||
echo "ok ${ntest}"
|
||||
else
|
||||
echo "not ok ${ntest}"
|
||||
fi
|
||||
ntest=`expr $ntest + 1`
|
||||
}
|
||||
|
||||
namegen()
|
||||
{
|
||||
echo "fstest_`dd if=/dev/random bs=1k count=1 2>/dev/null | openssl md5`"
|
||||
}
|
||||
|
||||
quick_exit()
|
||||
{
|
||||
echo "1..1"
|
||||
echo "ok 1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
supported()
|
||||
{
|
||||
case "${1}" in
|
||||
chflags)
|
||||
if [ ${os} != "FreeBSD" -o ${fs} != "UFS" ]; then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
lchmod)
|
||||
if [ ${os} != "FreeBSD" ]; then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
require()
|
||||
{
|
||||
if supported ${1}; then
|
||||
return
|
||||
fi
|
||||
quick_exit
|
||||
}
|
63
tools/regression/fstest/tests/mkdir/00.t
Normal file
63
tools/regression/fstest/tests/mkdir/00.t
Normal file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir creates directories"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..36"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n1}
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect dir,0755 lstat ${n0} type,mode
|
||||
expect 0 rmdir ${n0}
|
||||
expect 0 mkdir ${n0} 0151
|
||||
expect dir,0151 lstat ${n0} type,mode
|
||||
expect 0 rmdir ${n0}
|
||||
expect 0 -U 077 mkdir ${n0} 0151
|
||||
expect dir,0100 lstat ${n0} type,mode
|
||||
expect 0 rmdir ${n0}
|
||||
expect 0 -U 070 mkdir ${n0} 0345
|
||||
expect dir,0305 lstat ${n0} type,mode
|
||||
expect 0 rmdir ${n0}
|
||||
expect 0 -U 0501 mkdir ${n0} 0345
|
||||
expect dir,0244 lstat ${n0} type,mode
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 chown . 65535 65535
|
||||
expect 0 -u 65535 -g 65535 mkdir ${n0} 0755
|
||||
expect 65535,65535 lstat ${n0} uid,gid
|
||||
expect 0 rmdir ${n0}
|
||||
expect 0 -u 65535 -g 65534 mkdir ${n0} 0755
|
||||
expect 65535,65535 lstat ${n0} uid,gid
|
||||
expect 0 rmdir ${n0}
|
||||
expect 0 chmod . 0777
|
||||
expect 0 -u 65534 -g 65533 mkdir ${n0} 0755
|
||||
expect 65534,65535 lstat ${n0} uid,gid
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 chown . 0 0
|
||||
time=`${fstest} stat . ctime`
|
||||
sleep 1
|
||||
expect 0 mkdir ${n0} 0755
|
||||
atime=`${fstest} stat ${n0} atime`
|
||||
test_check $time -lt $atime
|
||||
mtime=`${fstest} stat ${n0} mtime`
|
||||
test_check $time -lt $mtime
|
||||
ctime=`${fstest} stat ${n0} ctime`
|
||||
test_check $time -lt $ctime
|
||||
mtime=`${fstest} stat . mtime`
|
||||
test_check $time -lt $mtime
|
||||
ctime=`${fstest} stat . ctime`
|
||||
test_check $time -lt $ctime
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n1}
|
18
tools/regression/fstest/tests/mkdir/01.t
Normal file
18
tools/regression/fstest/tests/mkdir/01.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns ENOTDIR if a component of the path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR mkdir ${n0}/${n1}/test 0755
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
13
tools/regression/fstest/tests/mkdir/02.t
Normal file
13
tools/regression/fstest/tests/mkdir/02.t
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..3"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 rmdir ${name255}
|
||||
expect ENAMETOOLONG mkdir ${name256} 0755
|
21
tools/regression/fstest/tests/mkdir/03.t
Normal file
21
tools/regression/fstest/tests/mkdir/03.t
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..11"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 mkdir ${path1023} 0755
|
||||
expect 0 rmdir ${path1023}
|
||||
expect ENAMETOOLONG mkdir ${path1024} 0755
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
16
tools/regression/fstest/tests/mkdir/04.t
Normal file
16
tools/regression/fstest/tests/mkdir/04.t
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns ENOENT if a component of the path prefix does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..3"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT mkdir ${n0}/${n1}/test 0755
|
||||
expect 0 rmdir ${n0}
|
29
tools/regression/fstest/tests/mkdir/05.t
Normal file
29
tools/regression/fstest/tests/mkdir/05.t
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns EACCES when search permission is denied for a component of the path prefix"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
|
||||
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
|
||||
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
29
tools/regression/fstest/tests/mkdir/06.t
Normal file
29
tools/regression/fstest/tests/mkdir/06.t
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns EACCES when write permission is denied on the parent directory of the directory to be created"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
|
||||
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
|
||||
expect 0 chmod ${n1} 0555
|
||||
expect EACCES -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
|
||||
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
19
tools/regression/fstest/tests/mkdir/07.t
Normal file
19
tools/regression/fstest/tests/mkdir/07.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns ELOOP if too many symbolic links were encountered in translating the pathname"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP mkdir ${n0}/test 0755
|
||||
expect ELOOP mkdir ${n1}/test 0755
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
53
tools/regression/fstest/tests/mkdir/08.t
Normal file
53
tools/regression/fstest/tests/mkdir/08.t
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns EPERM if the parent directory of the directory to be created has its immutable flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..30"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM mkdir ${n0}/${n1} 0755
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM mkdir ${n0}/${n1} 0755
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
|
||||
expect 0 rmdir ${n0}
|
34
tools/regression/fstest/tests/mkdir/09.t
Normal file
34
tools/regression/fstest/tests/mkdir/09.t
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns EROFS if the named file resides on a read-only file system"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..7"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
mount -ur /dev/md${n}
|
||||
expect EROFS mkdir ${n0}/${n1} 0755
|
||||
mount -uw /dev/md${n}
|
||||
expect 0 mkdir ${n0}/${n1} 0755
|
||||
expect 0 rmdir ${n0}/${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
27
tools/regression/fstest/tests/mkdir/10.t
Normal file
27
tools/regression/fstest/tests/mkdir/10.t
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns EEXIST if the named file exists"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect EEXIST mkdir ${n0} 0755
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect EEXIST mkdir ${n0} 0755
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 symlink test ${n0}
|
||||
expect EEXIST mkdir ${n0} 0755
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect EEXIST mkdir ${n0} 0755
|
||||
expect 0 unlink ${n0}
|
36
tools/regression/fstest/tests/mkdir/11.t
Normal file
36
tools/regression/fstest/tests/mkdir/11.t
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns ENOSPC if there are no free inodes on the file system on which the directory is being created"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..3"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 256k`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
i=0
|
||||
while :; do
|
||||
mkdir ${n0}/${i} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
expect ENOSPC mkdir ${n0}/${n1} 0755
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
12
tools/regression/fstest/tests/mkdir/12.t
Normal file
12
tools/regression/fstest/tests/mkdir/12.t
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkdir returns EFAULT if the path argument points outside the process's allocated address space"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..2"
|
||||
|
||||
expect EFAULT mkdir NULL 0755
|
||||
expect EFAULT mkdir DEADCODE 0755
|
63
tools/regression/fstest/tests/mkfifo/00.t
Normal file
63
tools/regression/fstest/tests/mkfifo/00.t
Normal file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo creates fifo files"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..36"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n1}
|
||||
|
||||
expect 0 mkfifo ${n0} 0755
|
||||
expect fifo,0755 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 mkfifo ${n0} 0151
|
||||
expect fifo,0151 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -U 077 mkfifo ${n0} 0151
|
||||
expect fifo,0100 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -U 070 mkfifo ${n0} 0345
|
||||
expect fifo,0305 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -U 0501 mkfifo ${n0} 0345
|
||||
expect fifo,0244 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 chown . 65535 65535
|
||||
expect 0 -u 65535 -g 65535 mkfifo ${n0} 0755
|
||||
expect 65535,65535 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -u 65535 -g 65534 mkfifo ${n0} 0755
|
||||
expect 65535,65535 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 chmod . 0777
|
||||
expect 0 -u 65534 -g 65533 mkfifo ${n0} 0755
|
||||
expect 65534,65535 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 chown . 0 0
|
||||
time=`${fstest} stat . ctime`
|
||||
sleep 1
|
||||
expect 0 mkfifo ${n0} 0755
|
||||
atime=`${fstest} stat ${n0} atime`
|
||||
test_check $time -lt $atime
|
||||
mtime=`${fstest} stat ${n0} mtime`
|
||||
test_check $time -lt $mtime
|
||||
ctime=`${fstest} stat ${n0} ctime`
|
||||
test_check $time -lt $ctime
|
||||
mtime=`${fstest} stat . mtime`
|
||||
test_check $time -lt $mtime
|
||||
ctime=`${fstest} stat . ctime`
|
||||
test_check $time -lt $ctime
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n1}
|
18
tools/regression/fstest/tests/mkfifo/01.t
Normal file
18
tools/regression/fstest/tests/mkfifo/01.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns ENOTDIR if a component of the path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR mkfifo ${n0}/${n1}/test 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
13
tools/regression/fstest/tests/mkfifo/02.t
Normal file
13
tools/regression/fstest/tests/mkfifo/02.t
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..3"
|
||||
|
||||
expect 0 mkfifo ${name255} 0644
|
||||
expect 0 unlink ${name255}
|
||||
expect ENAMETOOLONG mkfifo ${name256} 0644
|
21
tools/regression/fstest/tests/mkfifo/03.t
Normal file
21
tools/regression/fstest/tests/mkfifo/03.t
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..11"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 mkfifo ${path1023} 0644
|
||||
expect 0 unlink ${path1023}
|
||||
expect ENAMETOOLONG mkfifo ${path1024} 0644
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
16
tools/regression/fstest/tests/mkfifo/04.t
Normal file
16
tools/regression/fstest/tests/mkfifo/04.t
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns ENOENT if a component of the path prefix does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..3"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT mkfifo ${n0}/${n1}/test 0644
|
||||
expect 0 rmdir ${n0}
|
29
tools/regression/fstest/tests/mkfifo/05.t
Normal file
29
tools/regression/fstest/tests/mkfifo/05.t
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns EACCES when search permission is denied for a component of the path prefix"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
29
tools/regression/fstest/tests/mkfifo/06.t
Normal file
29
tools/regression/fstest/tests/mkfifo/06.t
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns EACCES when write permission is denied on the parent directory of the file to be created"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 chmod ${n1} 0555
|
||||
expect EACCES -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
19
tools/regression/fstest/tests/mkfifo/07.t
Normal file
19
tools/regression/fstest/tests/mkfifo/07.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns ELOOP if too many symbolic links were encountered in translating the pathname"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP mkfifo ${n0}/test 0644
|
||||
expect ELOOP mkfifo ${n1}/test 0644
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
34
tools/regression/fstest/tests/mkfifo/08.t
Normal file
34
tools/regression/fstest/tests/mkfifo/08.t
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns EROFS if the named file resides on a read-only file system"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..7"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 1m`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
mount -ur /dev/md${n}
|
||||
expect EROFS mkfifo ${n0}/${n1} 0644
|
||||
mount -uw /dev/md${n}
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
27
tools/regression/fstest/tests/mkfifo/09.t
Normal file
27
tools/regression/fstest/tests/mkfifo/09.t
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns EEXIST if the named file exists"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect EEXIST mkfifo ${n0} 0644
|
||||
expect 0 rmdir ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect EEXIST mkfifo ${n0} 0644
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 symlink test ${n0}
|
||||
expect EEXIST mkfifo ${n0} 0644
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 mkfifo ${n0} 0644
|
||||
expect EEXIST mkfifo ${n0} 0644
|
||||
expect 0 unlink ${n0}
|
53
tools/regression/fstest/tests/mkfifo/10.t
Normal file
53
tools/regression/fstest/tests/mkfifo/10.t
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns EPERM if the parent directory of the file to be created has its immutable flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..30"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM mkfifo ${n0}/${n1} 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM mkfifo ${n0}/${n1} 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 mkfifo ${n0}/${n1} 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
|
||||
expect 0 rmdir ${n0}
|
36
tools/regression/fstest/tests/mkfifo/11.t
Normal file
36
tools/regression/fstest/tests/mkfifo/11.t
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns ENOSPC if there are no free inodes on the file system on which the file is being created"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
case "${os}:${fs}" in
|
||||
FreeBSD:UFS)
|
||||
echo "1..3"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
n=`mdconfig -a -n -t malloc -s 256k`
|
||||
newfs /dev/md${n} >/dev/null
|
||||
mount /dev/md${n} ${n0}
|
||||
i=0
|
||||
while :; do
|
||||
mkfifo ${n0}/${i} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
expect ENOSPC mkfifo ${n0}/${n1} 0644
|
||||
umount /dev/md${n}
|
||||
mdconfig -d -u ${n}
|
||||
expect 0 rmdir ${n0}
|
||||
;;
|
||||
*)
|
||||
quick_exit
|
||||
;;
|
||||
esac
|
12
tools/regression/fstest/tests/mkfifo/12.t
Normal file
12
tools/regression/fstest/tests/mkfifo/12.t
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="mkfifo returns EFAULT if the path argument points outside the process's allocated address space"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..2"
|
||||
|
||||
expect EFAULT mkfifo NULL 0644
|
||||
expect EFAULT mkfifo DEADCODE 0644
|
87
tools/regression/fstest/tests/open/00.t
Normal file
87
tools/regression/fstest/tests/open/00.t
Normal file
@ -0,0 +1,87 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open opens (and eventually creates) a file"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..45"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n1} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n1}
|
||||
|
||||
expect 0 open ${n0} O_CREAT,O_WRONLY 0755
|
||||
expect regular,0755 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 open ${n0} O_CREAT,O_WRONLY 0151
|
||||
expect regular,0151 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -U 077 open ${n0} O_CREAT,O_WRONLY 0151
|
||||
expect regular,0100 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -U 070 open ${n0} O_CREAT,O_WRONLY 0345
|
||||
expect regular,0305 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -U 0501 open ${n0} O_CREAT,O_WRONLY 0345
|
||||
expect regular,0244 lstat ${n0} type,mode
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 chown . 65535 65535
|
||||
expect 0 -u 65535 -g 65535 open ${n0} O_CREAT,O_WRONLY 0644
|
||||
expect 65535,65535 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 -u 65535 -g 65534 open ${n0} O_CREAT,O_WRONLY 0644
|
||||
expect 65535,65535 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 chmod . 0777
|
||||
expect 0 -u 65534 -g 65533 open ${n0} O_CREAT,O_WRONLY 0644
|
||||
expect 65534,65535 lstat ${n0} uid,gid
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# Update parent directory ctime/mtime if file didn't exist.
|
||||
expect 0 chown . 0 0
|
||||
time=`${fstest} stat . ctime`
|
||||
sleep 1
|
||||
expect 0 open ${n0} O_CREAT,O_WRONLY 0644
|
||||
atime=`${fstest} stat ${n0} atime`
|
||||
test_check $time -lt $atime
|
||||
mtime=`${fstest} stat ${n0} mtime`
|
||||
test_check $time -lt $mtime
|
||||
ctime=`${fstest} stat ${n0} ctime`
|
||||
test_check $time -lt $ctime
|
||||
mtime=`${fstest} stat . mtime`
|
||||
test_check $time -lt $mtime
|
||||
ctime=`${fstest} stat . ctime`
|
||||
test_check $time -lt $ctime
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
# Don't update parent directory ctime/mtime if file existed.
|
||||
expect 0 create ${n0} 0644
|
||||
dmtime=`${fstest} stat . mtime`
|
||||
dctime=`${fstest} stat . ctime`
|
||||
sleep 1
|
||||
expect 0 open ${n0} O_CREAT,O_RDONLY 0644
|
||||
mtime=`${fstest} stat . mtime`
|
||||
test_check $dmtime -eq $mtime
|
||||
ctime=`${fstest} stat . ctime`
|
||||
test_check $dctime -eq $ctime
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
echo test > ${n0}
|
||||
mtime1=`${fstest} stat ${n0} mtime`
|
||||
ctime1=`${fstest} stat ${n0} ctime`
|
||||
sleep 1
|
||||
expect 0 open ${n0} O_WRONLY,O_TRUNC
|
||||
mtime2=`${fstest} stat ${n0} mtime`
|
||||
test_check $mtime1 -lt $mtime2
|
||||
ctime2=`${fstest} stat ${n0} ctime`
|
||||
test_check $ctime1 -lt $ctime2
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n1}
|
18
tools/regression/fstest/tests/open/01.t
Normal file
18
tools/regression/fstest/tests/open/01.t
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns ENOTDIR if a component of the path prefix is not a directory"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..5"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 create ${n0}/${n1} 0644
|
||||
expect ENOTDIR open ${n0}/${n1}/test O_CREAT 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
expect 0 rmdir ${n0}
|
14
tools/regression/fstest/tests/open/02.t
Normal file
14
tools/regression/fstest/tests/open/02.t
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..4"
|
||||
|
||||
expect 0 open ${name255} O_CREAT 0620
|
||||
expect 0620 stat ${name255} mode
|
||||
expect 0 unlink ${name255}
|
||||
expect ENAMETOOLONG open ${name256} O_CREAT 0620
|
22
tools/regression/fstest/tests/open/03.t
Normal file
22
tools/regression/fstest/tests/open/03.t
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
expect 0 mkdir ${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255} 0755
|
||||
expect 0 mkdir ${name255}/${name255}/${name255} 0755
|
||||
expect 0 mkdir ${path1021} 0755
|
||||
expect 0 open ${path1023} O_CREAT 0642
|
||||
expect 0642 stat ${path1023} mode
|
||||
expect 0 unlink ${path1023}
|
||||
expect ENAMETOOLONG open ${path1024} O_CREAT 0642
|
||||
expect 0 rmdir ${path1021}
|
||||
expect 0 rmdir ${name255}/${name255}/${name255}
|
||||
expect 0 rmdir ${name255}/${name255}
|
||||
expect 0 rmdir ${name255}
|
17
tools/regression/fstest/tests/open/04.t
Normal file
17
tools/regression/fstest/tests/open/04.t
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns ENOENT if a component of the path name that must exist does not exist or O_CREAT is not set and the named file does not exist"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..4"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect ENOENT open ${n0}/${n1}/test O_CREAT 0644
|
||||
expect ENOENT open ${n0}/${n1} O_RDONLY
|
||||
expect 0 rmdir ${n0}
|
29
tools/regression/fstest/tests/open/05.t
Normal file
29
tools/regression/fstest/tests/open/05.t
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EACCES when search permission is denied for a component of the path prefix"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..12"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
n2=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect 0 mkdir ${n1} 0755
|
||||
expect 0 chown ${n1} 65534 65534
|
||||
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
|
||||
expect 0 -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY
|
||||
expect 0 chmod ${n1} 0644
|
||||
expect EACCES -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY
|
||||
expect 0 chmod ${n1} 0755
|
||||
expect 0 -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
|
||||
expect 0 rmdir ${n1}
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
89
tools/regression/fstest/tests/open/06.t
Normal file
89
tools/regression/fstest/tests/open/06.t
Normal file
@ -0,0 +1,89 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..65"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 -u 65534 -g 65534 create ${n1} 0644
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0600
|
||||
expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
|
||||
expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY
|
||||
expect 0 -u 65534 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0060
|
||||
expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
|
||||
expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY
|
||||
expect 0 -u 65533 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0006
|
||||
expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
|
||||
expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY
|
||||
expect 0 -u 65533 -g 65533 open ${n1} O_RDWR
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0477
|
||||
expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0747
|
||||
expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0774
|
||||
expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0277
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
|
||||
expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0727
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
|
||||
expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0772
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
|
||||
expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0177
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0717
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0771
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0077
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0707
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0770
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
|
||||
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
45
tools/regression/fstest/tests/open/07.t
Normal file
45
tools/regression/fstest/tests/open/07.t
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EACCES when O_TRUNC is specified and write permission is denied"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..23"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
expect 0 chown ${n0} 65534 65534
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
|
||||
expect 0 -u 65534 -g 65534 create ${n1} 0644
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0477
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0747
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0774
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0177
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0717
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0771
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
|
||||
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0077
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0707
|
||||
expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
|
||||
expect 0 -u 65534 -g 65534 chmod ${n1} 0770
|
||||
expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
|
||||
|
||||
expect 0 -u 65534 -g 65534 unlink ${n1}
|
||||
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
19
tools/regression/fstest/tests/open/08.t
Normal file
19
tools/regression/fstest/tests/open/08.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EACCES when O_CREAT is specified, the file does not exist, and the directory in which it is to be created does not permit writing"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..3"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
cdir=`pwd`
|
||||
cd ${n0}
|
||||
expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_CREAT 0644
|
||||
cd ${cdir}
|
||||
expect 0 rmdir ${n0}
|
53
tools/regression/fstest/tests/open/09.t
Normal file
53
tools/regression/fstest/tests/open/09.t
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="O_CREAT is specified, the file does not exist, and the directory in which it is to be created has its immutable flag set"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..30"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
|
||||
expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 symlink test ${n0}/${n1}
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}/${n1}
|
||||
|
||||
expect 0 rmdir ${n0}
|
45
tools/regression/fstest/tests/open/10.t
Normal file
45
tools/regression/fstest/tests/open/10.t
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EPERM when the named file has its immutable flag set and the file is to be modified"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..28"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_IMMUTABLE
|
||||
expect EPERM open ${n0} O_WRONLY
|
||||
expect EPERM open ${n0} O_RDWR
|
||||
expect EPERM open ${n0} O_RDONLY,O_TRUNC
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_IMMUTABLE
|
||||
expect EPERM open ${n0} O_WRONLY
|
||||
expect EPERM open ${n0} O_RDWR
|
||||
expect EPERM open ${n0} O_RDONLY,O_TRUNC
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_NOUNLINK
|
||||
expect 0 open ${n0} O_WRONLY
|
||||
expect 0 open ${n0} O_RDWR
|
||||
expect 0 open ${n0} O_RDONLY,O_TRUNC
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_NOUNLINK
|
||||
expect 0 open ${n0} O_WRONLY
|
||||
expect 0 open ${n0} O_RDWR
|
||||
expect 0 open ${n0} O_RDONLY,O_TRUNC
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
39
tools/regression/fstest/tests/open/11.t
Normal file
39
tools/regression/fstest/tests/open/11.t
Normal file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EPERM when the named file has its append-only flag set, the file is to be modified, and O_TRUNC is specified or O_APPEND is not specified"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..24"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} SF_APPEND
|
||||
expect 0 open ${n0} O_WRONLY,O_APPEND
|
||||
expect 0 open ${n0} O_RDWR,O_APPEND
|
||||
expect EPERM open ${n0} O_WRONLY
|
||||
expect EPERM open ${n0} O_RDWR
|
||||
expect EPERM open ${n0} O_RDONLY,O_TRUNC
|
||||
expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC
|
||||
expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC
|
||||
expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
||||
|
||||
expect 0 create ${n0} 0644
|
||||
expect 0 chflags ${n0} UF_APPEND
|
||||
expect 0 open ${n0} O_WRONLY,O_APPEND
|
||||
expect 0 open ${n0} O_RDWR,O_APPEND
|
||||
expect EPERM open ${n0} O_WRONLY
|
||||
expect EPERM open ${n0} O_RDWR
|
||||
expect EPERM open ${n0} O_RDONLY,O_TRUNC
|
||||
expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC
|
||||
expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC
|
||||
expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC
|
||||
expect 0 chflags ${n0} none
|
||||
expect 0 unlink ${n0}
|
19
tools/regression/fstest/tests/open/12.t
Normal file
19
tools/regression/fstest/tests/open/12.t
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns ELOOP if too many symbolic links were encountered in translating the pathname"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
echo "1..6"
|
||||
|
||||
n0=`namegen`
|
||||
n1=`namegen`
|
||||
|
||||
expect 0 symlink ${n0} ${n1}
|
||||
expect 0 symlink ${n1} ${n0}
|
||||
expect ELOOP open ${n0}/test O_RDONLY
|
||||
expect ELOOP open ${n1}/test O_RDONLY
|
||||
expect 0 unlink ${n0}
|
||||
expect 0 unlink ${n1}
|
24
tools/regression/fstest/tests/open/13.t
Normal file
24
tools/regression/fstest/tests/open/13.t
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
desc="open returns EISDIR when he named file is a directory, and the arguments specify it is to be modified"
|
||||
|
||||
dir=`dirname $0`
|
||||
. ${dir}/../misc.sh
|
||||
|
||||
require chflags
|
||||
|
||||
echo "1..8"
|
||||
|
||||
n0=`namegen`
|
||||
|
||||
expect 0 mkdir ${n0} 0755
|
||||
|
||||
expect 0 open ${n0} O_RDONLY
|
||||
expect EISDIR open ${n0} O_WRONLY
|
||||
expect EISDIR open ${n0} O_RDWR
|
||||
expect EISDIR open ${n0} O_RDONLY,O_TRUNC
|
||||
expect EISDIR open ${n0} O_WRONLY,O_TRUNC
|
||||
expect EISDIR open ${n0} O_RDWR,O_TRUNC
|
||||
|
||||
expect 0 rmdir ${n0}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user