1 1.5 reinoud /* $NetBSD: nilfs_subr.h,v 1.5 2023/01/29 16:07:14 reinoud Exp $ */ 2 1.1 reinoud 3 1.1 reinoud /* 4 1.1 reinoud * Copyright (c) 2008, 2009 Reinoud Zandijk 5 1.1 reinoud * All rights reserved. 6 1.1 reinoud * 7 1.1 reinoud * Redistribution and use in source and binary forms, with or without 8 1.1 reinoud * modification, are permitted provided that the following conditions 9 1.1 reinoud * are met: 10 1.1 reinoud * 1. Redistributions of source code must retain the above copyright 11 1.1 reinoud * notice, this list of conditions and the following disclaimer. 12 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 reinoud * notice, this list of conditions and the following disclaimer in the 14 1.1 reinoud * documentation and/or other materials provided with the distribution. 15 1.1 reinoud * 16 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 reinoud * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 1.1 reinoud * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 1.1 reinoud * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 1.1 reinoud * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 1.1 reinoud * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 1.1 reinoud * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 1.1 reinoud * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 1.1 reinoud * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 1.1 reinoud * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 1.1 reinoud * 27 1.1 reinoud */ 28 1.1 reinoud 29 1.1 reinoud #ifndef _FS_NILFS_NILFS_SUBR_H_ 30 1.1 reinoud #define _FS_NILFS_NILFS_SUBR_H_ 31 1.1 reinoud 32 1.1 reinoud /* handies */ 33 1.1 reinoud #define VFSTONILFS(mp) ((struct nilfs_mount *)mp->mnt_data) 34 1.1 reinoud 35 1.1 reinoud /* basic calculators */ 36 1.1 reinoud uint64_t nilfs_get_segnum_of_block(struct nilfs_device *nilfsdev, uint64_t blocknr); 37 1.1 reinoud void nilfs_get_segment_range(struct nilfs_device *nilfsdev, uint64_t segnum, 38 1.1 reinoud uint64_t *seg_start, uint64_t *seg_end); 39 1.1 reinoud void nilfs_calc_mdt_consts(struct nilfs_device *nilfsdev, 40 1.1 reinoud struct nilfs_mdt *mdt, int entry_size); 41 1.1 reinoud uint32_t crc32_le(uint32_t crc, const uint8_t *buf, size_t len); 42 1.1 reinoud 43 1.1 reinoud /* log reading / volume helpers */ 44 1.1 reinoud int nilfs_get_segment_log(struct nilfs_device *nilfsdev, uint64_t *blocknr, 45 1.1 reinoud uint64_t *offset, struct buf **bpp, int len, void *blob); 46 1.1 reinoud void nilfs_search_super_root(struct nilfs_device *nilfsdev); 47 1.1 reinoud 48 1.1 reinoud /* reading */ 49 1.4 riastrad int nilfs_bread(struct nilfs_node *node, uint64_t blocknr, 50 1.1 reinoud int flags, struct buf **bpp); 51 1.1 reinoud 52 1.1 reinoud /* btree operations */ 53 1.1 reinoud int nilfs_btree_nlookup(struct nilfs_node *node, uint64_t from, uint64_t blks, uint64_t *l2vmap); 54 1.1 reinoud 55 1.1 reinoud /* vtop operations */ 56 1.3 hannken void nilfs_mdt_trans(struct nilfs_mdt *mdt, uint64_t index, uint64_t *blocknr, uint32_t *entry_in_block); 57 1.1 reinoud int nilfs_nvtop(struct nilfs_node *node, uint64_t blks, uint64_t *l2vmap, uint64_t *v2pmap); 58 1.1 reinoud 59 1.1 reinoud /* node action implementators */ 60 1.1 reinoud int nilfs_get_node_raw(struct nilfs_device *nilfsdev, struct nilfs_mount *ump, uint64_t ino, struct nilfs_inode *inode, struct nilfs_node **nodep); 61 1.1 reinoud void nilfs_dispose_node(struct nilfs_node **node); 62 1.1 reinoud 63 1.1 reinoud int nilfs_grow_node(struct nilfs_node *node, uint64_t new_size); 64 1.1 reinoud int nilfs_shrink_node(struct nilfs_node *node, uint64_t new_size); 65 1.1 reinoud void nilfs_itimes(struct nilfs_node *nilfs_node, struct timespec *acc, 66 1.1 reinoud struct timespec *mod, struct timespec *birth); 67 1.1 reinoud int nilfs_update(struct vnode *node, struct timespec *acc, 68 1.1 reinoud struct timespec *mod, struct timespec *birth, int updflags); 69 1.1 reinoud 70 1.1 reinoud /* return vpp? */ 71 1.1 reinoud int nilfs_lookup_name_in_dir(struct vnode *dvp, const char *name, int namelen, uint64_t *ino, int *found); 72 1.1 reinoud int nilfs_create_node(struct vnode *dvp, struct vnode **vpp, struct vattr *vap, struct componentname *cnp); 73 1.1 reinoud void nilfs_delete_node(struct nilfs_node *nilfs_node); 74 1.1 reinoud 75 1.1 reinoud int nilfs_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred); 76 1.1 reinoud int nilfs_dir_detach(struct nilfs_mount *ump, struct nilfs_node *dir_node, struct nilfs_node *nilfs_node, struct componentname *cnp); 77 1.1 reinoud int nilfs_dir_attach(struct nilfs_mount *ump, struct nilfs_node *dir_node, struct nilfs_node *nilfs_node, struct vattr *vap, struct componentname *cnp); 78 1.1 reinoud 79 1.1 reinoud 80 1.1 reinoud /* vnode operations */ 81 1.1 reinoud int nilfs_inactive(void *v); 82 1.1 reinoud int nilfs_reclaim(void *v); 83 1.1 reinoud int nilfs_readdir(void *v); 84 1.1 reinoud int nilfs_getattr(void *v); 85 1.1 reinoud int nilfs_setattr(void *v); 86 1.1 reinoud int nilfs_pathconf(void *v); 87 1.1 reinoud int nilfs_open(void *v); 88 1.1 reinoud int nilfs_close(void *v); 89 1.1 reinoud int nilfs_access(void *v); 90 1.1 reinoud int nilfs_read(void *v); 91 1.1 reinoud int nilfs_write(void *v); 92 1.1 reinoud int nilfs_trivial_bmap(void *v); 93 1.1 reinoud int nilfs_vfsstrategy(void *v); 94 1.1 reinoud int nilfs_lookup(void *v); 95 1.1 reinoud int nilfs_create(void *v); 96 1.1 reinoud int nilfs_mknod(void *v); 97 1.1 reinoud int nilfs_link(void *); 98 1.1 reinoud int nilfs_symlink(void *v); 99 1.1 reinoud int nilfs_readlink(void *v); 100 1.1 reinoud int nilfs_rename(void *v); 101 1.1 reinoud int nilfs_remove(void *v); 102 1.1 reinoud int nilfs_mkdir(void *v); 103 1.1 reinoud int nilfs_rmdir(void *v); 104 1.1 reinoud int nilfs_fsync(void *v); 105 1.1 reinoud int nilfs_advlock(void *v); 106 1.1 reinoud 107 1.1 reinoud #endif /* !_FS_NILFS_NILFS_SUBR_H_ */ 108