~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to lib/include/fileInt.h

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-15 21:21:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080815212140-05fhxj8wroosysmj
Tags: 2008.08.08-109361-1ubuntu1
* Merge from Debian unstable (LP: #258393), remaining Ubuntu change:
  - add ubuntu_toolchain_FTBFS.dpatch patch, fix FTBFS
* Update ubuntu_toolchain_FTBFS.dpatch patch for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************
2
 
 * Copyright (C) 2007 VMware, Inc. All rights reserved.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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.
16
 
 *
17
 
 *********************************************************/
18
 
 
19
 
/*
20
 
 * fileInt.h --
21
 
 *
22
 
 *      Things internal to the file library.
23
 
 */
24
 
 
25
 
#if !defined(__FILE_INTERNAL_H__)
26
 
#define __FILE_INTERNAL_H__
27
 
 
28
 
#define INCLUDE_ALLOW_USERLEVEL
29
 
#include "includeCheck.h"
30
 
#include "posix.h"
31
 
#include "fileIO.h"
32
 
#include "fileLock.h"
33
 
#include "unicodeTypes.h"
34
 
 
35
 
#if defined __linux__
36
 
/*
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,
39
 
 * think once more.
40
 
 */
41
 
 
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
49
 
 
50
 
#if !defined(MSDOS_SUPER_MAGIC)
51
 
#define MSDOS_SUPER_MAGIC     0x4D44
52
 
#endif
53
 
 
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
63
 
 
64
 
#if !defined(REISERFS_SUPER_MAGIC)
65
 
#define REISERFS_SUPER_MAGIC  0x52654973
66
 
#endif
67
 
#endif  // linux
68
 
 
69
 
#define LGPFX   "FILE:"
70
 
 
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
79
 
 
80
 
typedef struct FileData {
81
 
   uint64 fileAccessTime;
82
 
   uint64 fileCreationTime;
83
 
   uint64 fileModificationTime;
84
 
   uint64 fileSize;
85
 
   int    fileType;
86
 
   int    fileMode;
87
 
   int    fileOwner;
88
 
   int    fileGroup;
89
 
} FileData;
90
 
 
91
 
EXTERN int FileAttributes(ConstUnicode pathName,
92
 
                          FileData *fileData);
93
 
 
94
 
EXTERN int FileRename(ConstUnicode fromPath,
95
 
                      ConstUnicode toPath);
96
 
 
97
 
EXTERN int FileDeletion(ConstUnicode pathName,
98
 
                        Bool handleLink);
99
 
 
100
 
EXTERN int FileCreateDirectory(ConstUnicode pathName);
101
 
EXTERN int FileRemoveDirectory(ConstUnicode pathName);
102
 
 
103
 
#if defined(_WIN32)
104
 
EXTERN int FileMapErrorToErrno(char *functionName,
105
 
                               DWORD status);
106
 
#else
107
 
EXTERN char *FilePosixGetBlockDevice(char const *path);
108
 
#endif
109
 
 
110
 
typedef struct active_lock
111
 
{
112
 
  struct active_lock *next;
113
 
  uint32             age;
114
 
  Bool               marked;
115
 
  Unicode            dirName;
116
 
} ActiveLock;
117
 
 
118
 
typedef struct lock_values
119
 
{
120
 
   char         *machineID;
121
 
   char         *executionID;
122
 
   char         *payload;
123
 
   char         *lockType;
124
 
   Unicode      memberName;
125
 
   unsigned int lamportNumber;
126
 
   uint32       waitTime;
127
 
   uint32       msecMaxWaitTime;
128
 
   ActiveLock   *lockList;
129
 
} LockValues;
130
 
 
131
 
#include "file_extensions.h"
132
 
 
133
 
#define FILELOCK_SUFFIX "." LOCK_FILE_EXTENSION
134
 
 
135
 
#define FILELOCK_DATA_SIZE 512
136
 
 
137
 
#if defined(_WIN32)
138
 
typedef HANDLE FILELOCK_FILE_HANDLE;
139
 
#else
140
 
typedef int FILELOCK_FILE_HANDLE;
141
 
#endif
142
 
 
143
 
EXTERN const char *FileLockGetMachineID(void);
144
 
 
145
 
EXTERN Bool FileLockMachineIDMatch(char *host,
146
 
                                   char *second);
147
 
 
148
 
EXTERN int FileLockMemberValues(ConstUnicode lockDir, 
149
 
                                ConstUnicode fileName,
150
 
                                char *buffer,
151
 
                                uint32 size,
152
 
                                LockValues *memberValues);
153
 
 
154
 
EXTERN int FileLockHackVMX(const char *machineID,
155
 
                           const char *executionID,
156
 
                           ConstUnicode filePathName);
157
 
 
158
 
EXTERN int FileLockOpenFile(ConstUnicode pathName,
159
 
                            int flags,
160
 
                            FILELOCK_FILE_HANDLE *handle);
161
 
 
162
 
EXTERN int FileLockCloseFile(FILELOCK_FILE_HANDLE handle);
163
 
 
164
 
EXTERN int FileLockReadFile(FILELOCK_FILE_HANDLE handle,
165
 
                            void *buf,
166
 
                            uint32 requestedBytes,
167
 
                            uint32 *resultantBytes);
168
 
 
169
 
EXTERN int FileLockWriteFile(FILELOCK_FILE_HANDLE handle,
170
 
                             void *buf,
171
 
                             uint32 requestedBytes,
172
 
                             uint32 *resultantBytes);
173
 
 
174
 
EXTERN void *FileLockIntrinsic(const char *machineID,
175
 
                               const char *executionID,
176
 
                               const char *payload,
177
 
                               ConstUnicode filePathName,
178
 
                               Bool exclusivity,
179
 
                               uint32 msecMaxWaitTime,
180
 
                               int *err);
181
 
 
182
 
EXTERN int FileUnlockIntrinsic(const char *machineID,
183
 
                               const char *executionID,
184
 
                               ConstUnicode filePathName,
185
 
                               const void *lockToken);
186
 
 
187
 
EXTERN Bool FileLockValidOwner(const char *executionID,
188
 
                               const char *payload);
189
 
 
190
 
EXTERN Bool FileLockValidName(ConstUnicode fileName);
191
 
 
192
 
#if defined(__APPLE__)
193
 
EXTERN int PosixFileOpener(ConstUnicode pathName,
194
 
                           int flags,
195
 
                           mode_t mode);
196
 
#else
197
 
#define PosixFileOpener(a, b, c) Posix_Open(a, b, c);
198
 
#endif
199
 
 
200
 
#endif