1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 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 are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * 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 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ali Saidi 29 */ 30 31#ifndef __SOLARIS_HH__ 32#define __SOLARIS_HH__ 33#include "config/full_system.hh" 34 35#if FULL_SYSTEM 36 37class Solaris {}; 38 39#else //!FULL_SYSTEM 40 41#include <dirent.h> 42#include <errno.h> 43#include <fcntl.h> // for host open() flags 44#include <string.h> // for memset() 45#include <sys/stat.h> 46#include <sys/types.h> 47#include <unistd.h> 48 49#include "arch/isa_traits.hh" 50#include "sim/syscall_emul.hh" 51 52class TranslatingPort; 53 54/// 55/// This class encapsulates the types, structures, constants, 56/// functions, and syscall-number mappings specific to the Solaris 57/// syscall interface. 58/// 59class Solaris { 60 61 public: 62 63 //@{ 64 /// Basic Solaris types. 65 typedef uint64_t size_t; 66 typedef uint64_t off_t; 67 typedef int64_t time_t; 68 typedef int32_t uid_t; 69 typedef int32_t gid_t; 70 typedef uint64_t rlim_t; 71 typedef uint64_t ino_t; 72 typedef uint64_t dev_t; 73 typedef uint32_t mode_t; 74 typedef uint32_t nlink_t; 75 //@} 76
|
181 static void 182 copyOutStatBuf(TranslatingPort *mem, Addr addr, hst_stat *host) 183 { 184 using namespace TheISA; 185 186 TypedBufferArg<Solaris::tgt_stat> tgt(addr); 187 188 tgt->st_dev = htog(host->st_dev); 189 tgt->st_ino = htog(host->st_ino); 190 tgt->st_mode = htog(host->st_mode); 191 tgt->st_nlink = htog(host->st_nlink); 192 tgt->st_uid = htog(host->st_uid); 193 tgt->st_gid = htog(host->st_gid); 194 tgt->st_rdev = htog(host->st_rdev); 195 tgt->st_size = htog(host->st_size); 196 tgt->st_atimeX.tv_sec = htog((uint64_t)host->st_atime); 197 tgt->st_mtimeX.tv_sec = htog((uint64_t)host->st_mtime); 198 tgt->st_ctimeX.tv_sec = htog((uint64_t)host->st_ctime); 199#if defined(STAT_HAVE_NSEC) 200 tgt->st_atimeX.tv_nsec = htog(host->st_atime_nsec); 201 tgt->st_mtimeX.tv_nsec = htog(host->st_mtime_nsec); 202 tgt->st_ctimeX.tv_nsec = htog(host->st_ctime_nsec); 203#else 204 tgt->st_atimeX.tv_nsec = 0; 205 tgt->st_mtimeX.tv_nsec = 0; 206 tgt->st_ctimeX.tv_nsec = 0; 207#endif 208 tgt->st_blksize = htog(host->st_blksize); 209 tgt->st_blocks = htog(host->st_blocks); 210 strncpy(tgt->st_fstype, "????", 16); 211 212 tgt.copyOut(mem); 213 } 214#else 215 // Third version for bsd systems which no longer have any support for 216 // the old stat() call and stat() is actually a stat64() 217 static void 218 copyOutStatBuf(TranslatingPort *mem, Addr addr, hst_stat64 *host) 219 { 220 using namespace TheISA; 221 222 TypedBufferArg<Solaris::tgt_stat> tgt(addr); 223 224 tgt->st_dev = htog(host->st_dev); 225 tgt->st_ino = htog(host->st_ino); 226 tgt->st_mode = htog(host->st_mode); 227 tgt->st_nlink = htog(host->st_nlink); 228 tgt->st_uid = htog(host->st_uid); 229 tgt->st_gid = htog(host->st_gid); 230 tgt->st_rdev = htog(host->st_rdev); 231 tgt->st_size = htog(host->st_size); 232 tgt->st_atimeX.tv_sec = htog((uint64_t)host->st_atime); 233 tgt->st_mtimeX.tv_sec = htog((uint64_t)host->st_mtime); 234 tgt->st_ctimeX.tv_sec = htog((uint64_t)host->st_ctime); 235#if defined(STAT_HAVE_NSEC) 236 tgt->st_atimeX.tv_nsec = htog(host->st_atime_nsec); 237 tgt->st_mtimeX.tv_nsec = htog(host->st_mtime_nsec); 238 tgt->st_ctimeX.tv_nsec = htog(host->st_ctime_nsec); 239#else 240 tgt->st_atimeX.tv_nsec = 0; 241 tgt->st_mtimeX.tv_nsec = 0; 242 tgt->st_ctimeX.tv_nsec = 0; 243#endif 244 tgt->st_blksize = htog(host->st_blksize); 245 tgt->st_blocks = htog(host->st_blocks); 246 strncpy(tgt->st_fstype, "????", 16); 247 248 tgt.copyOut(mem); 249 } 250#endif 251 252 253 // Same for stat64 254 static void 255 copyOutStat64Buf(TranslatingPort *mem, int fd, Addr addr, hst_stat64 *host) 256 { 257 using namespace TheISA; 258 259 TypedBufferArg<Solaris::tgt_stat64> tgt(addr); 260 261 // fd == 1 checks are because libc does some checks 262 // that the stdout is interactive vs. a file 263 // this makes it work on non-solaris systems 264 if (fd == 1) 265 tgt->st_dev = htog((uint64_t)0xA); 266 else 267 tgt->st_dev = htog((uint64_t)host->st_dev); 268 // XXX What about STAT64_HAS_BROKEN_ST_INO ??? 269 tgt->st_ino = htog((uint64_t)host->st_ino); 270 if (fd == 1) 271 tgt->st_rdev = htog((uint64_t)0x880d); 272 else 273 tgt->st_rdev = htog((uint64_t)host->st_rdev); 274 tgt->st_size = htog((int64_t)host->st_size); 275 tgt->st_blocks = htog((uint64_t)host->st_blocks); 276 277 if (fd == 1) 278 tgt->st_mode = htog((uint32_t)0x2190); 279 else 280 tgt->st_mode = htog((uint32_t)host->st_mode); 281 tgt->st_uid = htog((uint32_t)host->st_uid); 282 tgt->st_gid = htog((uint32_t)host->st_gid); 283 tgt->st_blksize = htog((uint32_t)host->st_blksize); 284 tgt->st_nlink = htog((uint32_t)host->st_nlink); 285 tgt->st_atimeX.tv_sec = htog((uint64_t)host->st_atime); 286 tgt->st_mtimeX.tv_sec = htog((uint64_t)host->st_mtime); 287 tgt->st_ctimeX.tv_sec = htog((uint64_t)host->st_ctime); 288#if defined(STAT_HAVE_NSEC) 289 tgt->st_atimeX.tv_nsec = htog(host->st_atime_nsec); 290 tgt->st_mtimeX.tv_nsec = htog(host->st_mtime_nsec); 291 tgt->st_ctimeX.tv_nsec = htog(host->st_ctime_nsec); 292#else 293 tgt->st_atimeX.tv_nsec = 0; 294 tgt->st_mtimeX.tv_nsec = 0; 295 tgt->st_ctimeX.tv_nsec = 0; 296#endif 297 298 tgt.copyOut(mem); 299 } 300 301}; // class Solaris 302 303 304#endif // FULL_SYSTEM 305 306#endif // __SOLARIS_HH__
|