Boot-to-ramdisk image generation scripts
[minix3.git] / tests / fs / hfs / t_pathconvert.c
blob307de709be8bc457335c8cc904baf702ab097a34
1 /* $NetBSD: t_pathconvert.c,v 1.5 2011/02/25 20:54:18 martin Exp $ */
3 #include <sys/types.h>
4 #include <sys/mount.h>
6 #include <atf-c.h>
7 #include <dirent.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <limits.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <string.h>
16 #include <rump/rump.h>
17 #include <rump/rump_syscalls.h>
19 #include <fs/hfs/hfs.h>
21 #include "../../h_macros.h"
23 ATF_TC(colonslash);
24 ATF_TC_HEAD(colonslash, tc)
26 atf_tc_set_md_var(tc, "descr", "HFS+ colons/slashes (PR kern/44523)");
27 atf_tc_set_md_var(tc, "timeout", "20");
30 #define IMGNAME "colon.hfs"
31 #define FAKEBLK "/dev/blk"
32 #define FUNNY_FILENAME "foo:bar"
33 ATF_TC_BODY(colonslash, tc)
35 struct hfs_args args;
36 int dirfd, fd;
37 char thecmd[1024];
38 char buf[DIRBLKSIZ];
39 struct dirent *dirent;
40 int offset, nbytes;
41 bool ok = false;
43 snprintf(thecmd, sizeof(thecmd), "uudecode %s/colon.hfs.bz2.uue",
44 atf_tc_get_config_var(tc, "srcdir"));
45 RZ(system(thecmd));
47 snprintf(thecmd, sizeof(thecmd), "bunzip2 " IMGNAME ".bz2");
48 RZ(system(thecmd));
50 memset(&args, 0, sizeof args);
51 args.fspec = __UNCONST(FAKEBLK);
52 RZ(rump_init());
54 RL(rump_sys_mkdir("/mp", 0777));
55 RZ(rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK));
56 RL(rump_sys_mount(MOUNT_HFS, "/mp", 0, &args, sizeof args));
58 RL(dirfd = rump_sys_open("/mp", O_RDONLY));
60 RL(nbytes = rump_sys_getdents(dirfd, buf, sizeof buf));
62 for (offset = 0; offset < nbytes; offset += dirent->d_reclen) {
63 dirent = (struct dirent *)(buf + offset);
64 if (strchr(dirent->d_name, '/'))
65 atf_tc_fail("dirent with slash: %s", dirent->d_name);
66 if (0 == strcmp(FUNNY_FILENAME, dirent->d_name))
67 ok = true;
70 if (!ok)
71 atf_tc_fail("no dirent for file: %s", FUNNY_FILENAME);
73 RL(rump_sys_close(dirfd));
74 RL(fd = rump_sys_open("/mp/" FUNNY_FILENAME, O_RDONLY));
75 RL(rump_sys_close(fd));
76 RL(rump_sys_unmount("/mp", 0));
79 ATF_TP_ADD_TCS(tp)
81 ATF_TP_ADD_TC(tp, colonslash);
82 return 0;