PERFORCE change 154987 for review
Robert Watson
rwatson at FreeBSD.org
Fri Dec 19 03:37:50 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=154987
Change 154987 by rwatson at rwatson_cinnamon on 2008/12/19 11:37:40
Generate error tokens for test purposes.
Affected files ...
.. //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#12 edit
Differences ...
==== //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#12 (text+ko) ====
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#11 $
+ * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#12 $
*/
/*
@@ -966,6 +966,74 @@
write_record(directory, record_filename, socketex_token, AUE_NULL);
}
+/*
+ * Generate a series of error-number specific return tokens in records.
+ */
+static void
+generate_error_record(const char *directory, const char *filename, int error)
+{
+ char pathname[PATH_MAX];
+ token_t *return32_token;
+
+ return32_token = au_to_return32(au_errno_to_bsm(error), -1);
+ if (return32_token == NULL)
+ err(EX_UNAVAILABLE, "au_to_return32");
+ (void)snprintf(pathname, PATH_MAX, "%s_record", filename);
+ write_record(directory, pathname, return32_token, AUE_NULL);
+}
+
+/*
+ * Not all the error numbers, just a few present on all platforms for now.
+ */
+const struct {
+ int error_number;
+ const char *error_name;
+} error_list[] = {
+ { EPERM, "EPERM" },
+ { ENOENT, "ENOENT" },
+ { ESRCH, "ESRCH" },
+ { EINTR, "EINTR" },
+ { EIO, "EIO" },
+ { ENXIO, "ENXIO" },
+ { E2BIG, "E2BIG" },
+ { ENOEXEC, "ENOEXEC" },
+ { EBADF, "EBADF" },
+ { ECHILD, "ECHILD" },
+ { EDEADLK, "EDEADLK" },
+ { ENOMEM, "ENOMEM" },
+ { EACCES, "EACCES" },
+ { EFAULT, "EFAULT" },
+ { ENOTBLK, "ENOTBLK" },
+ { EBUSY, "EBUSY" },
+ { EEXIST, "EEXIST" },
+ { EXDEV, "EXDEV" },
+ { ENODEV, "ENODEV" },
+ { ENOTDIR, "ENOTDIR" },
+ { EISDIR, "EISDIR" },
+ { EINVAL, "EINVAL" },
+ { ENFILE, "ENFILE" },
+ { EMFILE, "EMFILE" },
+ { ENOTTY, "ENOTTY" },
+ { ETXTBSY, "ETXTBSY" },
+ { EFBIG, "EFBIG" },
+ { ENOSPC, "ENOSPC" },
+ { ESPIPE, "ESPIPE" },
+ { EROFS, "EROFS" },
+ { EMLINK, "EMLINK" },
+ { EPIPE, "EPIPE" }
+};
+const int error_list_count = sizeof(error_list)/sizeof(error_list[0]);
+
+static void
+do_error_records(const char *directory)
+{
+ int i;
+
+ for (i = 0; i < error_list_count; i++)
+ generate_error_record(directory, error_list[i].error_name,
+ error_list[i].error_number);
+}
+
int
main(int argc, char *argv[])
{
@@ -1070,6 +1138,7 @@
generate_attr32_record(directory, "attr32_record");
generate_zonename_record(directory, "zonename_record");
generate_socketex_record(directory, "socketex_record");
+ do_error_records(directory);
}
return (0);
More information about the p4-projects
mailing list