Mon Aug 9 17:42:26 2010 UTC ()
Check that mounting a file system with blocksize > MAXPHYS returns an error.


(pooka)
diff -r1.7 -r1.8 src/tests/fs/ffs/t_mount.c

cvs diff -r1.7 -r1.8 src/tests/fs/ffs/t_mount.c (expand / switch to unified diff)

--- src/tests/fs/ffs/t_mount.c 2010/07/30 16:15:05 1.7
+++ src/tests/fs/ffs/t_mount.c 2010/08/09 17:42:26 1.8
@@ -1,29 +1,46 @@ @@ -1,29 +1,46 @@
1/* $NetBSD: t_mount.c,v 1.7 2010/07/30 16:15:05 pooka Exp $ */ 1/* $NetBSD: t_mount.c,v 1.8 2010/08/09 17:42:26 pooka Exp $ */
2 2
3/* 3/*
 4 * Basic tests for mounting
 5 */
 6
 7/*
 8 * 48Kimage:
4 * Adapted for rump and atf from a testcase supplied 9 * Adapted for rump and atf from a testcase supplied
5 * by Hubert Feyrer on netbsd-users@ 10 * by Hubert Feyrer on netbsd-users@
6 */ 11 */
7 12
8#include <atf-c.h> 13#include <atf-c.h>
9 14
10#define IMGNAME "image.ffs" 15#define IMGNAME "image.ffs"
11#define IMGSIZE (96 * 512) 16#define IMGSIZE (96 * 512)
12 17
13#define MNTDIR "/mnt" 18#define MNTDIR "/mnt"
14 19
15#include "../common/h_fsmacros.h" 20#include "../common/h_fsmacros.h"
16 21
 22#include <sys/types.h>
 23#include <sys/mount.h>
 24
 25#include <stdlib.h>
 26
 27#include <ufs/ufs/ufsmount.h>
 28
 29#include <rump/rump.h>
 30#include <rump/rump_syscalls.h>
 31
 32#include "../../h_macros.h"
 33
17ATF_TC(48Kimage); 34ATF_TC(48Kimage);
18ATF_TC_HEAD(48Kimage, tc) 35ATF_TC_HEAD(48Kimage, tc)
19{ 36{
20 atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image"); 37 atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image");
21 atf_tc_set_md_var(tc, "use.fs", "true"); 38 atf_tc_set_md_var(tc, "use.fs", "true");
22} 39}
23 40
24ATF_TC_BODY(48Kimage, tc) 41ATF_TC_BODY(48Kimage, tc)
25{ 42{
26 void *tmp; 43 void *tmp;
27 44
28 if (ffs_fstest_newfs(tc, &tmp, IMGNAME, IMGSIZE, NULL) != 0) 45 if (ffs_fstest_newfs(tc, &tmp, IMGNAME, IMGSIZE, NULL) != 0)
29 atf_tc_fail("newfs failed"); 46 atf_tc_fail("newfs failed");
@@ -31,18 +48,63 @@ ATF_TC_BODY(48Kimage, tc) @@ -31,18 +48,63 @@ ATF_TC_BODY(48Kimage, tc)
31 atf_tc_expect_fail("PR kern/43573"); 48 atf_tc_expect_fail("PR kern/43573");
32 if (ffs_fstest_mount(tc, tmp, MNTDIR, 0) != 0) { 49 if (ffs_fstest_mount(tc, tmp, MNTDIR, 0) != 0) {
33 atf_tc_fail("mount failed"); 50 atf_tc_fail("mount failed");
34 } 51 }
35 atf_tc_expect_pass(); 52 atf_tc_expect_pass();
36 53
37 if (ffs_fstest_unmount(tc, MNTDIR, 0) != 0) 54 if (ffs_fstest_unmount(tc, MNTDIR, 0) != 0)
38 atf_tc_fail("unmount failed"); 55 atf_tc_fail("unmount failed");
39 56
40 if (ffs_fstest_delfs(tc, tmp) != 0) 57 if (ffs_fstest_delfs(tc, tmp) != 0)
41 atf_tc_fail("delfs failed"); 58 atf_tc_fail("delfs failed");
42} 59}
43 60
 61ATF_TC(fsbsize2big);
 62ATF_TC_HEAD(fsbsize2big, tc)
 63{
 64
 65 atf_tc_set_md_var(tc, "descr", "mounts file system with "
 66 "blocksize > MAXPHYS");
 67 atf_tc_set_md_var(tc, "use.fs", "true");
 68 /* PR kern/43727 */
 69}
 70
 71#define MYBLOCKSIZE 131072
 72#if MAXPHYS >= MYBLOCKSIZE
 73#error MAXPHYS too large for test to work
 74#endif
 75ATF_TC_BODY(fsbsize2big, tc)
 76{
 77 char cmd[1024];
 78 struct ufs_args args;
 79 struct statvfs svb;
 80
 81 snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 "
 82 "ffs.img > /dev/null", MYBLOCKSIZE);
 83 if (system(cmd))
 84 atf_tc_fail("cannot create file system");
 85
 86 rump_init();
 87 if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK))
 88 atf_tc_fail("cannot register rump fake device");
 89
 90 args.fspec = __UNCONST("/devdisk");
 91
 92 if (rump_sys_mkdir("/mp", 0777) == -1)
 93 atf_tc_fail_errno("create mountpoint");
 94
 95 /* mount succeeded? bad omen. confirm we're in trouble. */
 96 if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) {
 97 rump_sys_statvfs1("/mp", &svb, ST_WAIT);
 98 }
 99
 100 /* otherwise we're do-ne */
 101}
 102
44ATF_TP_ADD_TCS(tp) 103ATF_TP_ADD_TCS(tp)
45{ 104{
 105
46 ATF_TP_ADD_TC(tp, 48Kimage); 106 ATF_TP_ADD_TC(tp, 48Kimage);
 107 ATF_TP_ADD_TC(tp, fsbsize2big);
 108
47 return atf_no_error(); 109 return atf_no_error();
48} 110}