1 /* $NetBSD: v7fs_dirent.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_dirent.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>
51 #include "v7fs_impl.h"
52 #include "v7fs_endian.h"
53 #include "v7fs_inode.h"
54 #include "v7fs_dirent.h"
56 #ifdef V7FS_DIRENT_DEBUG
57 #define DPRINTF(fmt, args...) printf("%s: " fmt, __func__, ##args)
59 #define DPRINTF(fmt, args...) ((void)0)
63 v7fs_dirent_endian_convert(struct v7fs_self
*fs
, struct v7fs_dirent
*dir
, int n
)
65 struct v7fs_superblock
*sb
= &fs
->superblock
;
70 for (i
= 0; i
< n
; i
++, dir
++) {
71 ino
= V7FS_VAL16(fs
, dir
->inode_number
);
72 if (v7fs_inode_number_sanity(sb
, ino
)) {
73 DPRINTF("Invalid inode# %d %s\n", ino
, dir
->name
);
76 dir
->inode_number
= ino
;
83 v7fs_dirent_filename(char *dst
/* size must be V7FS_NAME_MAX + 1 */,
87 strncpy(dst
, src
, V7FS_NAME_MAX
);
88 dst
[V7FS_NAME_MAX
] = '\0';