1
/*********************************************************
2
* Copyright (C) 2007 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
22
* Things internal to the file library.
25
#if !defined(__FILE_INTERNAL_H__)
26
#define __FILE_INTERNAL_H__
28
#define INCLUDE_ALLOW_USERLEVEL
29
#include "includeCheck.h"
33
#include "unicodeTypes.h"
37
* These magic constants are used only for parsing Linux statfs data.
38
* So they make sense only for Linux build. If you need them on other OSes,
42
#define AFFS_SUPER_MAGIC 0xADFF
43
#define EXT_SUPER_MAGIC 0x137D
44
#define EXT2_OLD_SUPER_MAGIC 0xEF51
45
#define EXT2_SUPER_MAGIC 0xEF53
46
#define HFSPLUS_SUPER_MAGIC 0x482B
47
#define NFS_SUPER_MAGIC 0x6969
48
#define SMB_SUPER_MAGIC 0x517B
50
#if !defined(MSDOS_SUPER_MAGIC)
51
#define MSDOS_SUPER_MAGIC 0x4D44
54
#define XENIX_SUPER_MAGIC 0x012FF7B4
55
#define SYSV4_SUPER_MAGIC 0x012FF7B5
56
#define SYSV2_SUPER_MAGIC 0x012FF7B6
57
#define COH_SUPER_MAGIC 0x012FF7B7
58
#define UFS_SUPER_MAGIC 0x00011954
59
#define XFS_SUPER_MAGIC 0x58465342
60
#define VMFS_SUPER_MAGIC 0x2fABF15E
61
#define TMPFS_SUPER_MAGIC 0x01021994
62
#define JFS_SUPER_MAGIC 0x3153464A
64
#if !defined(REISERFS_SUPER_MAGIC)
65
#define REISERFS_SUPER_MAGIC 0x52654973
71
#define FILE_TYPE_REGULAR 0
72
#define FILE_TYPE_DIRECTORY 1
73
#define FILE_TYPE_BLOCKDEVICE 2
74
#define FILE_TYPE_CHARDEVICE 3
75
#define FILE_TYPE_SYMLINK 4
76
#define FILE_TYPE_FIFO 5
77
#define FILE_TYPE_SOCKET 6
78
#define FILE_TYPE_UNCERTAIN 7
80
typedef struct FileData {
81
uint64 fileAccessTime;
82
uint64 fileCreationTime;
83
uint64 fileModificationTime;
91
EXTERN int FileAttributes(ConstUnicode pathName,
94
EXTERN int FileRename(ConstUnicode fromPath,
97
EXTERN int FileDeletion(ConstUnicode pathName,
100
EXTERN int FileCreateDirectory(ConstUnicode pathName);
101
EXTERN int FileRemoveDirectory(ConstUnicode pathName);
104
EXTERN int FileMapErrorToErrno(char *functionName,
107
EXTERN char *FilePosixGetBlockDevice(char const *path);
110
typedef struct active_lock
112
struct active_lock *next;
118
typedef struct lock_values
125
unsigned int lamportNumber;
127
uint32 msecMaxWaitTime;
128
ActiveLock *lockList;
131
#include "file_extensions.h"
133
#define FILELOCK_SUFFIX "." LOCK_FILE_EXTENSION
135
#define FILELOCK_DATA_SIZE 512
138
typedef HANDLE FILELOCK_FILE_HANDLE;
140
typedef int FILELOCK_FILE_HANDLE;
143
EXTERN const char *FileLockGetMachineID(void);
145
EXTERN Bool FileLockMachineIDMatch(char *host,
148
EXTERN int FileLockMemberValues(ConstUnicode lockDir,
149
ConstUnicode fileName,
152
LockValues *memberValues);
154
EXTERN int FileLockHackVMX(const char *machineID,
155
const char *executionID,
156
ConstUnicode filePathName);
158
EXTERN int FileLockOpenFile(ConstUnicode pathName,
160
FILELOCK_FILE_HANDLE *handle);
162
EXTERN int FileLockCloseFile(FILELOCK_FILE_HANDLE handle);
164
EXTERN int FileLockReadFile(FILELOCK_FILE_HANDLE handle,
166
uint32 requestedBytes,
167
uint32 *resultantBytes);
169
EXTERN int FileLockWriteFile(FILELOCK_FILE_HANDLE handle,
171
uint32 requestedBytes,
172
uint32 *resultantBytes);
174
EXTERN void *FileLockIntrinsic(const char *machineID,
175
const char *executionID,
177
ConstUnicode filePathName,
179
uint32 msecMaxWaitTime,
182
EXTERN int FileUnlockIntrinsic(const char *machineID,
183
const char *executionID,
184
ConstUnicode filePathName,
185
const void *lockToken);
187
EXTERN Bool FileLockValidOwner(const char *executionID,
188
const char *payload);
190
EXTERN Bool FileLockValidName(ConstUnicode fileName);
192
#if defined(__APPLE__)
193
EXTERN int PosixFileOpener(ConstUnicode pathName,
197
#define PosixFileOpener(a, b, c) Posix_Open(a, b, c);