#include <sys/types.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/disklabel.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <util.h>
#include <dev/dm/netbsd-dm.h>
int dm_test_targets(void);
int dm_test_versions(void);
int
dm_test_versions(void) {
int fd;
int error;
prop_dictionary_t dict_in, dict_out;
struct plistref prefp;
char *xml;
error = 0;
error = rump_init();
if (error != 0)
err(1, "Rump init failed");
fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0);
if (fd == -1)
err(1, "Open dm device failed");
dict_in = prop_dictionary_internalize_from_file("dm_version_cmd.plist");
dict_out = prop_dictionary_create();
prop_dictionary_externalize_to_pref(dict_in, &prefp);
error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp);
if (error < 0)
err(1, "Dm control ioctl failed");
dict_out = prop_dictionary_internalize(prefp.pref_plist);
xml = prop_dictionary_externalize(dict_out);
__USE(xml);
rump_sys_close(fd);
return error;
}
int
dm_test_targets(void) {
int fd;
int error;
prop_dictionary_t dict_in, dict_out;
struct plistref prefp;
char *xml;
error = 0;
error = rump_init();
if (error != 0)
err(1, "Rump init failed");
fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0);
if (fd == -1)
err(1, "Open dm device failed");
dict_in = prop_dictionary_internalize_from_file("dm_targets_cmd.plist");
dict_out = prop_dictionary_create();
prop_dictionary_externalize_to_pref(dict_in, &prefp);
error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp);
if (error < 0)
err(1, "Dm control ioctl failed");
dict_out = prop_dictionary_internalize(prefp.pref_plist);
xml = prop_dictionary_externalize(dict_out);
__USE(xml);
rump_sys_close(fd);
return error;
}
int
main(int argc, char **argv) {
int error;
error = 0;
error = dm_test_versions();
if (error != 0)
err(1, "dm_test_versions failed");
error = dm_test_targets();
if (error != 0)
err(1, "dm_test_targets failed");
return error;
}