VirtualBox

source: kBuild/trunk/src/lib/nt/ntstat.h@ 2802

Last change on this file since 2802 was 2708, checked in by bird, 12 years ago

Optimized ftsfake.c for windows (similar things can be done for OS/2, if we care).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1/* $Id: ntstat.h 2708 2013-11-21 10:26:40Z bird $ */
2/** @file
3 * MSC + NT stat, lstat and fstat implementation and wrappers.
4 */
5
6/*
7 * Copyright (c) 2005-2013 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 *
27 * Alternatively, the content of this file may be used under the terms of the
28 * GPL version 2 or later, or LGPL version 2.1 or later.
29 */
30
31#ifndef ___nt_ntstat_h
32#define ___nt_ntstat_h
33
34#include "nttypes.h"
35
36#include <sys/stat.h>
37#include <io.h>
38#include <direct.h>
39
40#undef stat
41#undef lstat
42#undef fstat
43
44
45/** The distance between the NT and unix epochs given in NT time (units of 100
46 * ns). */
47#define BIRD_NT_EPOCH_OFFSET_UNIX_100NS 116444736000000000LL
48
49typedef struct BirdStat
50{
51 unsigned __int16 st_mode;
52 unsigned __int16 st_dirsymlink;
53 unsigned __int16 st_padding0[2];
54 __int64 st_size;
55 BirdTimeSpec_T st_atim;
56 BirdTimeSpec_T st_mtim;
57 BirdTimeSpec_T st_ctim;
58 BirdTimeSpec_T st_birthtim;
59 unsigned __int64 st_ino;
60 unsigned __int64 st_dev;
61 unsigned __int32 st_nlink;
62 unsigned __int16 st_rdev;
63 __int16 st_uid;
64 __int16 st_gid;
65 unsigned __int16 st_padding1[3];
66 unsigned __int32 st_blksize;
67 __int64 st_blocks;
68} BirdStat_T;
69
70#define BIRD_STAT_BLOCK_SIZE 512
71
72#define st_atime st_atim.tv_sec
73#define st_ctime st_ctim.tv_sec
74#define st_mtime st_mtim.tv_sec
75#define st_birthtime st_birthtim.tv_sec
76
77int birdStatFollowLink(const char *pszPath, BirdStat_T *pStat);
78int birdStatOnLink(const char *pszPath, BirdStat_T *pStat);
79int birdStatOnFd(int fd, BirdStat_T *pStat);
80int birdStatModTimeOnly(const char *pszPath, BirdTimeSpec_T *pTimeSpec, int fFollowLink);
81#ifdef ___nt_ntstuff_h
82void birdStatFillFromFileIdFullDirInfo(BirdStat_T *pStat, MY_FILE_ID_FULL_DIR_INFORMATION const *pBuf, const char *pszPath);
83#endif
84
85#define STAT_REDEFINED_ALREADY
86
87#define stat BirdStat
88#define BirdStat(a_pszPath, a_pStat) birdStatFollowLink(a_pszPath, a_pStat)
89#define lstat(a_pszPath, a_pStat) birdStatOnLink(a_pszPath, a_pStat)
90#define fstat(a_fd, a_pStat) birdStatOnFd(a_fd, a_pStat)
91
92
93#ifndef _S_IFLNK
94# define _S_IFLNK 0xa000
95#endif
96#ifndef S_IFLNK
97# define S_IFLNK _S_IFLNK
98#endif
99#ifndef S_IFIFO
100# define S_IFIFO _S_IFIFO
101#endif
102
103#ifndef S_ISLNK
104# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
105#endif
106#ifndef S_ISDIR
107# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
108#endif
109#ifndef S_ISREG
110# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
111#endif
112
113#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
114#define S_IXUSR _S_IEXEC
115#define S_IWUSR _S_IWRITE
116#define S_IRUSR _S_IREAD
117#define S_IRWXG 0000070
118#define S_IRGRP 0000040
119#define S_IWGRP 0000020
120#define S_IXGRP 0000010
121#define S_IRWXO 0000007
122#define S_IROTH 0000004
123#define S_IWOTH 0000002
124#define S_IXOTH 0000001
125#define S_ISUID 0004000
126#define S_ISGID 0002000
127#define ALLPERMS 0000777
128
129#endif
130
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette