1 /* File-I/O functions for GDB, the GNU debugger.
3 Copyright (C) 2003-2015 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "common-defs.h"
27 host_to_fileio_error (int error
)
52 return FILEIO_ENOTDIR
;
72 return FILEIO_ENAMETOOLONG
;
74 return FILEIO_EUNKNOWN
;
77 /* Convert a host-format mode_t into a bitmask of File-I/O flags. */
80 fileio_mode_pack (mode_t mode
)
85 tmode
|= FILEIO_S_IFREG
;
87 tmode
|= FILEIO_S_IFDIR
;
89 tmode
|= FILEIO_S_IFCHR
;
91 tmode
|= FILEIO_S_IRUSR
;
93 tmode
|= FILEIO_S_IWUSR
;
95 tmode
|= FILEIO_S_IXUSR
;
98 tmode
|= FILEIO_S_IRGRP
;
102 tmode
|= FILEIO_S_IWGRP
;
106 tmode
|= FILEIO_S_IXGRP
;
109 tmode
|= FILEIO_S_IROTH
;
112 tmode
|= FILEIO_S_IWOTH
;
116 tmode
|= FILEIO_S_IXOTH
;
121 /* Pack a host-format mode_t into an fio_mode_t. */
124 host_to_fileio_mode (mode_t num
, fio_mode_t fnum
)
126 host_to_bigendian (fileio_mode_pack (num
), (char *) fnum
, 4);
129 /* Pack a host-format integer into an fio_ulong_t. */
132 host_to_fileio_ulong (LONGEST num
, fio_ulong_t fnum
)
134 host_to_bigendian (num
, (char *) fnum
, 8);
140 host_to_fileio_stat (struct stat
*st
, struct fio_stat
*fst
)
144 host_to_fileio_uint ((long) st
->st_dev
, fst
->fst_dev
);
145 host_to_fileio_uint ((long) st
->st_ino
, fst
->fst_ino
);
146 host_to_fileio_mode (st
->st_mode
, fst
->fst_mode
);
147 host_to_fileio_uint ((long) st
->st_nlink
, fst
->fst_nlink
);
148 host_to_fileio_uint ((long) st
->st_uid
, fst
->fst_uid
);
149 host_to_fileio_uint ((long) st
->st_gid
, fst
->fst_gid
);
150 host_to_fileio_uint ((long) st
->st_rdev
, fst
->fst_rdev
);
151 host_to_fileio_ulong ((LONGEST
) st
->st_size
, fst
->fst_size
);
152 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
153 blksize
= st
->st_blksize
;
157 host_to_fileio_ulong (blksize
, fst
->fst_blksize
);
158 #if HAVE_STRUCT_STAT_ST_BLOCKS
159 host_to_fileio_ulong ((LONGEST
) st
->st_blocks
, fst
->fst_blocks
);
161 /* FIXME: This is correct for DJGPP, but other systems that don't
162 have st_blocks, if any, might prefer 512 instead of st_blksize.
163 (eliz, 30-12-2003) */
164 host_to_fileio_ulong (((LONGEST
) st
->st_size
+ blksize
- 1)
168 host_to_fileio_time (st
->st_atime
, fst
->fst_atime
);
169 host_to_fileio_time (st
->st_mtime
, fst
->fst_mtime
);
170 host_to_fileio_time (st
->st_ctime
, fst
->fst_ctime
);
This page took 0.034311 seconds and 4 git commands to generate.