Back to index

glibc  2.9
xstatconv.c
Go to the documentation of this file.
00001 /* Convert between the kernel's `struct stat' format, and libc's.
00002    Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <errno.h>
00021 #include <string.h>
00022 #include <sys/stat.h>
00023 #include <kernel_stat.h>
00024 #include <xstatconv.h>
00025 
00026 
00027 int __libc_missing_axp_stat64;
00028 
00029 int
00030 __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
00031 {
00032   switch (vers)
00033     {
00034     case _STAT_VER_KERNEL:
00035       *(struct kernel_stat *) ubuf = *kbuf;
00036       break;
00037 
00038     case _STAT_VER_GLIBC2:
00039       {
00040        struct glibc2_stat *buf = ubuf;
00041 
00042        buf->st_dev = kbuf->st_dev;
00043        buf->st_ino = kbuf->st_ino;
00044        buf->st_mode = kbuf->st_mode;
00045        buf->st_nlink = kbuf->st_nlink;
00046        buf->st_uid = kbuf->st_uid;
00047        buf->st_gid = kbuf->st_gid;
00048        buf->st_rdev = kbuf->st_rdev;
00049        buf->st_size = kbuf->st_size;
00050        buf->st_atime = kbuf->st_atime;
00051        buf->st_mtime = kbuf->st_mtime;
00052        buf->st_ctime = kbuf->st_ctime;
00053        buf->st_blksize = kbuf->st_blksize;
00054        buf->st_blocks = kbuf->st_blocks;
00055        buf->st_flags = kbuf->st_flags;
00056        buf->st_gen = kbuf->st_gen;
00057       }
00058       break;
00059 
00060     case _STAT_VER_GLIBC2_1:
00061       {
00062        struct glibc21_stat *buf = ubuf;
00063 
00064        buf->st_dev = kbuf->st_dev;
00065        buf->st_ino = kbuf->st_ino;
00066        buf->st_mode = kbuf->st_mode;
00067        buf->st_nlink = kbuf->st_nlink;
00068        buf->st_uid = kbuf->st_uid;
00069        buf->st_gid = kbuf->st_gid;
00070        buf->st_rdev = kbuf->st_rdev;
00071        buf->st_size = kbuf->st_size;
00072        buf->st_atime = kbuf->st_atime;
00073        buf->st_mtime = kbuf->st_mtime;
00074        buf->st_ctime = kbuf->st_ctime;
00075        buf->st_blocks = kbuf->st_blocks;
00076        buf->st_blksize = kbuf->st_blksize;
00077        buf->st_flags = kbuf->st_flags;
00078        buf->st_gen = kbuf->st_gen;
00079        buf->__pad3 = 0;
00080        buf->__unused[0] = 0;
00081        buf->__unused[1] = 0;
00082        buf->__unused[2] = 0;
00083        buf->__unused[3] = 0;
00084       }
00085       break;
00086 
00087     case _STAT_VER_GLIBC2_3_4:
00088       {
00089        struct stat64 *buf = ubuf;
00090 
00091        buf->st_dev = kbuf->st_dev;
00092        buf->st_ino = kbuf->st_ino;
00093        buf->st_rdev = kbuf->st_rdev;
00094        buf->st_size = kbuf->st_size;
00095        buf->st_blocks = kbuf->st_blocks;
00096 
00097        buf->st_mode = kbuf->st_mode;
00098        buf->st_uid = kbuf->st_uid;
00099        buf->st_gid = kbuf->st_gid;
00100        buf->st_blksize = kbuf->st_blksize;
00101        buf->st_nlink = kbuf->st_nlink;
00102        buf->__pad0 = 0;
00103 
00104        buf->st_atime = kbuf->st_atime;
00105        buf->st_atimensec = 0;
00106        buf->st_mtime = kbuf->st_mtime;
00107        buf->st_mtimensec = 0;
00108        buf->st_ctime = kbuf->st_ctime;
00109        buf->st_ctimensec = 0;
00110 
00111        buf->__unused[0] = 0;
00112        buf->__unused[1] = 0;
00113        buf->__unused[2] = 0;
00114       }
00115       break;
00116 
00117     default:
00118       __set_errno (EINVAL);
00119       return -1;
00120     }
00121 
00122   return 0;
00123 }