Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Nov 2008 19:56:40 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185219 - head/tools/regression/fstest
Message-ID:  <200811231956.mANJueje062314@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811231956.mANJueje062314>