1 /* $NetBSD: v7fs_superblock_util.c,v 1.2 2011/07/18 21:51:49 apb Exp $ */
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #if HAVE_NBTOOL_CONFIG_H
33 #include "nbtool_config.h"
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: v7fs_superblock_util.c,v 1.2 2011/07/18 21:51:49 apb Exp $");
38 #if defined _KERNEL_OPT
43 #include <sys/systm.h>
44 #include <sys/param.h> /* errno */
51 #include "v7fs_impl.h"
52 #include "v7fs_superblock.h"
53 #include "v7fs_inode.h"
55 #ifdef V7FS_SUPERBLOCK_DEBUG
56 #define DPRINTF(fmt, args...) printf("%s: " fmt, __func__, ##args)
57 #define DPRINTF_(fmt, args...) printf(fmt, ##args)
59 #define DPRINTF(fmt, args...) ((void)0)
60 #define DPRINTF_(fmt, args...) ((void)0)
64 v7fs_superblock_status(struct v7fs_self
*fs
)
66 struct v7fs_superblock
*sb
= &fs
->superblock
;
67 struct v7fs_stat
*stat
= &fs
->stat
;
69 stat
->total_blocks
= sb
->volume_size
- sb
->datablock_start_sector
;
70 stat
->total_inode
= V7FS_MAX_INODE(sb
);
71 stat
->free_inode
= sb
->total_freeinode
;
72 stat
->free_blocks
= sb
->total_freeblock
;
73 stat
->total_files
= stat
->total_inode
- sb
->total_freeinode
- 1;
75 DPRINTF("block %d/%d, inode %d/%d\n", stat
->free_blocks
,
76 stat
->total_blocks
, stat
->free_inode
, stat
->total_inode
);
80 v7fs_superblock_dump(const struct v7fs_self
*fs
)
82 const struct v7fs_superblock
*sb
= &fs
->superblock
;
84 #define print(x) printf("%s: %d\n", #x, sb->x)
85 print(datablock_start_sector
);
90 print(lock_freeblock
);
91 print(lock_freeinode
);
95 time_t t
= sb
->update_time
;
96 printf("%s", ctime(&t
));
98 print(total_freeblock
);
99 print(total_freeinode
);