diff options
author | pjd <pjd@FreeBSD.org> | 2008-11-23 19:56:40 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2008-11-23 19:56:40 +0000 |
commit | ad301e0dc017d4e892bf3e4ca086ea5892303bf2 (patch) | |
tree | b8243a8bf8b90196e50f6bc4dcb34937c74772e3 | |
parent | 9367195ae8e4ae1330dbbdf4448915967a6af437 (diff) | |
download | FreeBSD-src-ad301e0dc017d4e892bf3e4ca086ea5892303bf2.zip FreeBSD-src-ad301e0dc017d4e892bf3e4ca086ea5892303bf2.tar.gz |
Add support for pathconf(2).
-rw-r--r-- | tools/regression/fstest/fstest.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/tools/regression/fstest/fstest.c b/tools/regression/fstest/fstest.c index 886b90f..05950c9 100644 --- a/tools/regression/fstest/fstest.c +++ b/tools/regression/fstest/fstest.c @@ -75,6 +75,7 @@ enum action { ACTION_TRUNCATE, ACTION_STAT, ACTION_LSTAT, + ACTION_PATHCONF }; #define TYPE_NONE 0x0000 @@ -116,6 +117,7 @@ static struct syscall_desc syscalls[] = { { "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 } }, + { "pathconf", ACTION_PATHCONF, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { NULL, -1, { TYPE_NONE } } }; @@ -209,6 +211,27 @@ static struct flag chflags_flags[] = { }; #endif +struct name { + int n_name; + char *n_str; +}; + +static struct name pathconf_names[] = { +#ifdef _PC_LINK_MAX + { _PC_LINK_MAX, "_PC_LINK_MAX" }, +#endif +#ifdef _PC_NAME_MAX + { _PC_NAME_MAX, "_PC_NAME_MAX" }, +#endif +#ifdef _PC_PATH_MAX + { _PC_PATH_MAX, "_PC_PATH_MAX" }, +#endif +#ifdef _PC_SYMLINK_MAX + { _PC_SYMLINK_MAX, "_PC_SYMLINK_MAX" }, +#endif + { 0, NULL } +}; + static const char *err2str(int error); static void @@ -264,6 +287,18 @@ flags2str(struct flag *tflags, long long flags) } #endif +static int +str2name(struct name *names, char *name) +{ + unsigned int i; + + for (i = 0; names[i].n_str != NULL; i++) { + if (strcmp(names[i].n_str, name) == 0) + return (names[i].n_name); + } + return (-1); +} + static struct syscall_desc * find_syscall(const char *name) { @@ -357,7 +392,7 @@ call_syscall(struct syscall_desc *scall, char *argv[]) long long flags; unsigned int i; char *endp; - int rval; + int name, rval; union { char *str; long long num; @@ -484,6 +519,27 @@ call_syscall(struct syscall_desc *scall, char *argv[]) return (i); } break; + case ACTION_PATHCONF: + { + long lrval; + + name = str2name(pathconf_names, STR(1)); + if (name == -1) { + fprintf(stderr, "unknown name %s", STR(1)); + exit(1); + } + errno = 0; + lrval = pathconf(STR(0), name); + if (lrval == -1 && errno == 0) { + printf("unlimited\n"); + return (i); + } else if (lrval >= 0) { + printf("%ld\n", lrval); + return (i); + } + rval = -1; + break; + } default: fprintf(stderr, "unsupported syscall\n"); exit(1); |