|
Packit |
6c4009 |
/* Convert between the kernel's `struct stat' format, and libc's.
|
|
Packit |
6c4009 |
Copyright (C) 1997-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library. If not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <errno.h>
|
|
Packit |
6c4009 |
#include <string.h>
|
|
Packit |
6c4009 |
#include <sys/stat.h>
|
|
Packit |
6c4009 |
#include <kernel_stat.h>
|
|
Packit |
6c4009 |
#include <xstatconv.h>
|
|
Packit |
6c4009 |
#include <sys/syscall.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int
|
|
Packit |
6c4009 |
__xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
switch (vers)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
case _STAT_VER_KERNEL:
|
|
Packit |
6c4009 |
*(struct kernel_stat *) ubuf = *kbuf;
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
case _STAT_VER_GLIBC2:
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
struct glibc2_stat *buf = ubuf;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
buf->st_dev = kbuf->st_dev;
|
|
Packit |
6c4009 |
buf->st_ino = kbuf->st_ino;
|
|
Packit |
6c4009 |
buf->st_mode = kbuf->st_mode;
|
|
Packit |
6c4009 |
buf->st_nlink = kbuf->st_nlink;
|
|
Packit |
6c4009 |
buf->st_uid = kbuf->st_uid;
|
|
Packit |
6c4009 |
buf->st_gid = kbuf->st_gid;
|
|
Packit |
6c4009 |
buf->st_rdev = kbuf->st_rdev;
|
|
Packit |
6c4009 |
buf->st_size = kbuf->st_size;
|
|
Packit |
6c4009 |
buf->st_atime = kbuf->st_atime;
|
|
Packit |
6c4009 |
buf->st_mtime = kbuf->st_mtime;
|
|
Packit |
6c4009 |
buf->st_ctime = kbuf->st_ctime;
|
|
Packit |
6c4009 |
buf->st_blksize = kbuf->st_blksize;
|
|
Packit |
6c4009 |
buf->st_blocks = kbuf->st_blocks;
|
|
Packit |
6c4009 |
buf->st_flags = kbuf->st_flags;
|
|
Packit |
6c4009 |
buf->st_gen = kbuf->st_gen;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
case _STAT_VER_GLIBC2_1:
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
struct glibc21_stat *buf = ubuf;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
buf->st_dev = kbuf->st_dev;
|
|
Packit |
6c4009 |
buf->st_ino = kbuf->st_ino;
|
|
Packit |
6c4009 |
buf->st_mode = kbuf->st_mode;
|
|
Packit |
6c4009 |
buf->st_nlink = kbuf->st_nlink;
|
|
Packit |
6c4009 |
buf->st_uid = kbuf->st_uid;
|
|
Packit |
6c4009 |
buf->st_gid = kbuf->st_gid;
|
|
Packit |
6c4009 |
buf->st_rdev = kbuf->st_rdev;
|
|
Packit |
6c4009 |
buf->st_size = kbuf->st_size;
|
|
Packit |
6c4009 |
buf->st_atime = kbuf->st_atime;
|
|
Packit |
6c4009 |
buf->st_mtime = kbuf->st_mtime;
|
|
Packit |
6c4009 |
buf->st_ctime = kbuf->st_ctime;
|
|
Packit |
6c4009 |
buf->st_blocks = kbuf->st_blocks;
|
|
Packit |
6c4009 |
buf->st_blksize = kbuf->st_blksize;
|
|
Packit |
6c4009 |
buf->st_flags = kbuf->st_flags;
|
|
Packit |
6c4009 |
buf->st_gen = kbuf->st_gen;
|
|
Packit |
6c4009 |
buf->__pad3 = 0;
|
|
Packit |
6c4009 |
buf->__glibc_reserved[0] = 0;
|
|
Packit |
6c4009 |
buf->__glibc_reserved[1] = 0;
|
|
Packit |
6c4009 |
buf->__glibc_reserved[2] = 0;
|
|
Packit |
6c4009 |
buf->__glibc_reserved[3] = 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
case _STAT_VER_GLIBC2_3_4:
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
struct stat64 *buf = ubuf;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
buf->st_dev = kbuf->st_dev;
|
|
Packit |
6c4009 |
buf->st_ino = kbuf->st_ino;
|
|
Packit |
6c4009 |
buf->st_rdev = kbuf->st_rdev;
|
|
Packit |
6c4009 |
buf->st_size = kbuf->st_size;
|
|
Packit |
6c4009 |
buf->st_blocks = kbuf->st_blocks;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
buf->st_mode = kbuf->st_mode;
|
|
Packit |
6c4009 |
buf->st_uid = kbuf->st_uid;
|
|
Packit |
6c4009 |
buf->st_gid = kbuf->st_gid;
|
|
Packit |
6c4009 |
buf->st_blksize = kbuf->st_blksize;
|
|
Packit |
6c4009 |
buf->st_nlink = kbuf->st_nlink;
|
|
Packit |
6c4009 |
buf->__pad0 = 0;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
buf->st_atime = kbuf->st_atime;
|
|
Packit |
6c4009 |
buf->st_atimensec = 0;
|
|
Packit |
6c4009 |
buf->st_mtime = kbuf->st_mtime;
|
|
Packit |
6c4009 |
buf->st_mtimensec = 0;
|
|
Packit |
6c4009 |
buf->st_ctime = kbuf->st_ctime;
|
|
Packit |
6c4009 |
buf->st_ctimensec = 0;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
buf->__glibc_reserved[0] = 0;
|
|
Packit |
6c4009 |
buf->__glibc_reserved[1] = 0;
|
|
Packit |
6c4009 |
buf->__glibc_reserved[2] = 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
default:
|
|
Packit |
6c4009 |
__set_errno (EINVAL);
|
|
Packit |
6c4009 |
return -1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|