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