1 /* $NetBSD: t_pathconvert.c,v 1.5 2011/02/25 20:54:18 martin Exp $ */
16 #include <rump/rump.h>
17 #include <rump/rump_syscalls.h>
19 #include <fs/hfs/hfs.h>
21 #include "../../h_macros.h"
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
)
39 struct dirent
*dirent
;
43 snprintf(thecmd
, sizeof(thecmd
), "uudecode %s/colon.hfs.bz2.uue",
44 atf_tc_get_config_var(tc
, "srcdir"));
47 snprintf(thecmd
, sizeof(thecmd
), "bunzip2 " IMGNAME
".bz2");
50 memset(&args
, 0, sizeof args
);
51 args
.fspec
= __UNCONST(FAKEBLK
);
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
))
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));
81 ATF_TP_ADD_TC(tp
, colonslash
);