1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/* $NetBSD: t_mount.c,v 1.14 2017/01/13 21:30:39 christos Exp $ */
/*
* Basic tests for mounting
*/
/*
* 48Kimage:
* Adapted for rump and atf from a testcase supplied
* by Hubert Feyrer on netbsd-users@
*/
#include <atf-c.h>
#define FSTEST_IMGSIZE (96 * 512)
#include "../common/h_fsmacros.h"
#include <sys/types.h>
#include <sys/mount.h>
#include <stdlib.h>
#include <ufs/ufs/ufsmount.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
#include "h_macros.h"
ATF_TC(48Kimage);
ATF_TC_HEAD(48Kimage, tc)
{
atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image");
}
ATF_TC_BODY(48Kimage, tc)
{
void *tmp;
atf_tc_expect_fail("PR kern/43573");
FSTEST_CONSTRUCTOR(tc, ffs, tmp);
atf_tc_expect_pass();
FSTEST_DESTRUCTOR(tc, ffs, tmp);
}
ATF_TC(fsbsizeovermaxphys);
ATF_TC_HEAD(fsbsizeovermaxphys, tc)
{
atf_tc_set_md_var(tc, "descr", "mounts file system with "
"blocksize > MAXPHYS");
/* PR kern/43727 */
}
ATF_TC_BODY(fsbsizeovermaxphys, tc)
{
char cmd[1024];
struct ufs_args args;
struct statvfs svb;
/*
* We cannot pass newfs parameters via the fstest interface,
* so do things the oldfashioned manual way.
*/
snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 "
"ffs.img > /dev/null", MAXPHYS * 2);
if (system(cmd))
atf_tc_fail("cannot create file system");
rump_init();
if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK))
atf_tc_fail("cannot register rump fake device");
args.fspec = __UNCONST("/devdisk");
if (rump_sys_mkdir("/mp", 0777) == -1)
atf_tc_fail_errno("create mountpoint");
/* mount succeeded? bad omen. confirm we're in trouble. */
if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) {
rump_sys_statvfs1("/mp", &svb, ST_WAIT);
atf_tc_fail("not expecting to be alive");
}
/* otherwise we're do-ne */
}
ATF_TC(fsbsizeovermaxbsize);
ATF_TC_HEAD(fsbsizeovermaxbsize, tc)
{
atf_tc_set_md_var(tc, "descr", "mounts file system with "
"blocksize > MAXBSIZE");
}
ATF_TC_BODY(fsbsizeovermaxbsize, tc)
{
char cmd[1024];
struct ufs_args args;
struct statvfs svb;
/*
* We cannot pass newfs parameters via the fstest interface,
* so do things the oldfashioned manual way.
*/
snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 "
"ffs.img > /dev/null", MAXBSIZE * 2);
if (system(cmd))
atf_tc_fail("cannot create file system");
rump_init();
if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK))
atf_tc_fail("cannot register rump fake device");
args.fspec = __UNCONST("/devdisk");
if (rump_sys_mkdir("/mp", 0777) == -1)
atf_tc_fail_errno("create mountpoint");
/* mount succeeded? bad omen. confirm we're in trouble. */
if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) {
rump_sys_statvfs1("/mp", &svb, ST_WAIT);
atf_tc_fail("not expecting to be alive");
}
/* otherwise we're do-ne */
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, 48Kimage);
ATF_TP_ADD_TC(tp, fsbsizeovermaxphys);
ATF_TP_ADD_TC(tp, fsbsizeovermaxbsize);
return atf_no_error();
}
|