1/*- 2 * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29/* 30 * Forward compatibility shim to convert old stat buffer to 31 * new so we can call the old system call, but return data in 32 * the new system call's format. 33 */ 34#define _WANT_FREEBSD11_STATFS 35#include <sys/fcntl.h> 36#include <sys/mount.h> 37 38#define _WANT_FREEBSD11_STAT 39#include <sys/stat.h> 40 41#include <string.h> 42 43#define INO64_FIRST 1200031 44 45static __inline void 46__stat11_to_stat(const struct freebsd11_stat *sb11, struct stat *sb) 47{ 48 49 sb->st_dev = sb11->st_dev; 50 sb->st_ino = sb11->st_ino; 51 sb->st_nlink = sb11->st_nlink; 52 sb->st_mode = sb11->st_mode; 53 sb->st_uid = sb11->st_uid; 54 sb->st_gid = sb11->st_gid; 55 sb->st_rdev = sb11->st_rdev; 56 sb->st_atim = sb11->st_atim; 57 sb->st_mtim = sb11->st_mtim; 58 sb->st_ctim = sb11->st_ctim; 59#ifdef __STAT_TIME_T_EXT 60 sb->st_atim_ext = 0; 61 sb->st_mtim_ext = 0; 62 sb->st_ctim_ext = 0; 63 sb->st_btim_ext = 0; 64#endif 65 sb->st_birthtim = sb11->st_birthtim; 66 sb->st_size = sb11->st_size; 67 sb->st_blocks = sb11->st_blocks; 68 sb->st_blksize = sb11->st_blksize; 69 sb->st_flags = sb11->st_flags; 70 sb->st_gen = sb11->st_gen; 71 sb->st_padding0 = 0; 72 sb->st_padding1 = 0; 73 memset(sb->st_spare, 0, sizeof(sb->st_spare)); 74} 75 76static __inline void 77__statfs11_to_statfs(const struct freebsd11_statfs *sf11, struct statfs *sf) 78{ 79 80 sf->f_version = STATFS_VERSION; 81 sf->f_type = sf11->f_type; 82 sf->f_flags = sf11->f_flags; 83 sf->f_bsize = sf11->f_bsize; 84 sf->f_iosize = sf11->f_iosize; 85 sf->f_blocks = sf11->f_blocks; 86 sf->f_bfree = sf11->f_bfree; 87 sf->f_bavail = sf11->f_bavail; 88 sf->f_files = sf11->f_files; 89 sf->f_ffree = sf11->f_ffree; 90 sf->f_syncwrites = sf11->f_syncwrites; 91 sf->f_asyncwrites = sf11->f_asyncwrites; 92 sf->f_syncreads = sf11->f_syncreads; 93 sf->f_asyncreads = sf11->f_asyncreads; 94 sf->f_namemax = sf11->f_namemax; 95 sf->f_owner = sf11->f_owner; 96 sf->f_fsid = sf11->f_fsid; 97 memset(sf->f_spare, 0, sizeof(sf->f_spare)); 98 memset(sf->f_charspare, 0, sizeof(sf->f_charspare)); 99 strlcpy(sf->f_fstypename, sf11->f_fstypename, sizeof(sf->f_fstypename)); 100 strlcpy(sf->f_mntfromname, sf11->f_mntfromname, sizeof(sf->f_mntfromname)); 101 strlcpy(sf->f_mntonname, sf11->f_mntonname, sizeof(sf->f_mntonname)); 102} 103