PERFORCE change 173920 for review
Jonathan Anderson
jona at FreeBSD.org
Fri Jan 29 19:15:13 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=173920
Change 173920 by jona at jona-capsicum-kent64 on 2010/01/29 19:14:39
Basic testing of lc_fdlist stuff
Affected files ...
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/fdlist/fdlist.c#6 edit
Differences ...
==== //depot/projects/trustedbsd/capabilities/src/tools/cap/fdlist/fdlist.c#6 (text+ko) ====
@@ -57,6 +57,8 @@
int
main(int argc, char *argv[])
{
+ printf("fdlist\n");
+
/* create an FD list and add some junk to it */
struct lc_fdlist *fds = lc_fdlist_new();
if (fds == NULL) err(-1, "Error in lc_fdlist_new()");
@@ -92,7 +94,7 @@
struct lc_fdlist *copy = (struct lc_fdlist*) shm;
if (find_junk(copy) < 0) err(-1, "Error in find_junk(copy)");
- printf("OK\n");
+ printf("Starting sandbox...\n");
/* run sandbox */
@@ -118,14 +120,18 @@
printf("cap_main() alive\n"); fflush(stdout);
struct lc_fdlist *global_fdlist = lc_fdlist_global();
- if (find_junk(global_fdlist) < 0)
- err(-1, "Error in find_junk(global_fdlist)");
+ int result = find_junk(global_fdlist);
+
+ if (result < 0) err(-1, "Error in find_junk(global_fdlist)");
+ else if (result == 0) printf("find_junk() found no FD entries\n");
struct lc_fdlist *copy = lc_fdlist_dup(global_fdlist);
- if (find_junk(copy) < 0)
- err(-1, "Error in find_junk(copy)");
+ result = find_junk(copy);
+
+ if (result < 0) err(-1, "Error in find_junk(copy)");
+ else if (result == 0) printf("find_junk() found no FD entries\n");
- printf("OK\n");
+ printf("Received FD list OK\n"); fflush(stdout);
return 0;
}
@@ -144,6 +150,8 @@
int find_junk(struct lc_fdlist *fds)
{
int pos = 0;
+ int parsed = 0;
+
for (int i = 0; i < 20; i++) {
char *name;
int value;
@@ -157,8 +165,10 @@
if (value != 50 + i)
warnx("i=%i\tGot 'FD' %i instead of %i", i, value, 50 + i);
+
+ parsed++;
}
- return 0;
+ return parsed;
}
More information about the p4-projects
mailing list