Remove building with NOCRYPTO option
[minix3.git] / sys / fs / v7fs / v7fs_dirent.c
blob99431e7b6a68b3cd8daca903d3023c198b84579c
1 /* $NetBSD: v7fs_dirent.c,v 1.2 2011/07/18 21:51:49 apb Exp $ */
3 /*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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"
34 #endif
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
39 #include "opt_v7fs.h"
40 #endif
42 #ifdef _KERNEL
43 #include <sys/systm.h>
44 #include <sys/param.h>
45 #else
46 #include <stdio.h>
47 #include <string.h>
48 #endif
50 #include "v7fs.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)
58 #else
59 #define DPRINTF(fmt, args...) ((void)0)
60 #endif
62 bool
63 v7fs_dirent_endian_convert(struct v7fs_self *fs, struct v7fs_dirent *dir, int n)
65 struct v7fs_superblock *sb = &fs->superblock;
66 int i;
67 v7fs_ino_t ino;
68 bool ok = true;
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);
74 ok = false;
76 dir->inode_number = ino;
79 return ok;
82 void
83 v7fs_dirent_filename(char *dst/* size must be V7FS_NAME_MAX + 1 */,
84 const char *src)
87 strncpy(dst, src, V7FS_NAME_MAX);
88 dst[V7FS_NAME_MAX] = '\0';