From owner-svn-src-head@FreeBSD.ORG Sun Nov 23 19:56:40 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF44C1065672; Sun, 23 Nov 2008 19:56:40 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC8F98FC25; Sun, 23 Nov 2008 19:56:40 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mANJueF7062316; Sun, 23 Nov 2008 19:56:40 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mANJueje062314; Sun, 23 Nov 2008 19:56:40 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <200811231956.mANJueje062314@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 23 Nov 2008 19:56:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185219 - head/tools/regression/fstest X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Nov 2008 19:56:40 -0000 Author: pjd Date: Sun Nov 23 19:56:40 2008 New Revision: 185219 URL: http://svn.freebsd.org/changeset/base/185219 Log: Add support for pathconf(2). Modified: head/tools/regression/fstest/fstest.c Modified: head/tools/regression/fstest/fstest.c ============================================================================== --- head/tools/regression/fstest/fstest.c Sun Nov 23 19:56:09 2008 (r185218) +++ head/tools/regression/fstest/fstest.c Sun Nov 23 19:56:40 2008 (r185219) @@ -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 } #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, 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, 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);