~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to lib/include/file.h

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
#include "fileIO.h"
38
38
#include "unicodeTypes.h"
 
39
#include "err.h"
39
40
 
40
41
#ifdef N_PLAT_NLM
41
42
#define FILE_MAXPATH    256
47
48
# endif
48
49
# if defined(__FreeBSD__)
49
50
#  include <sys/syslimits.h>  // PATH_MAX
50
 
# else 
 
51
# else
51
52
#  include <limits.h>  // PATH_MAX
52
 
# endif 
 
53
# endif
53
54
#define FILE_MAXPATH    PATH_MAX
54
55
#endif
55
56
 
63
64
typedef struct WalkDirContextImpl WalkDirContextImpl;
64
65
typedef const WalkDirContextImpl *WalkDirContext;
65
66
 
 
67
/*
 
68
 * When File_MakeTempEx2 is called, it creates a temporary file or a directory
 
69
 * in a specified directory. File_MakeTempEx2 calls a user-specified callback
 
70
 * function to get the filename. Callback function should be of type
 
71
 * File_MakeTempCreateNameFunc.
 
72
 *
 
73
 * 'num' specifies nth time this function is called.
 
74
 *
 
75
 * 'data' specifies the payload that the user specified when executing
 
76
 * File_MakeTempEx2 function.
 
77
 *
 
78
 * If successful, this function should return a dynamically allocated string
 
79
 * with the filename.
 
80
 *
 
81
 * File_MakeTempEx2 frees the fileName after a successful call to this
 
82
 * function.
 
83
 *
 
84
 */
 
85
 
 
86
typedef Unicode File_MakeTempCreateNameFunc(int num,
 
87
                                            void *data);
 
88
 
66
89
#if defined(__APPLE__)
67
90
typedef enum {
68
91
   FILEMACOS_UNMOUNT_SUCCESS,
70
93
   FILEMACOS_UNMOUNT_ERROR,
71
94
} FileMacosUnmountStatus;
72
95
 
73
 
EXTERN FileMacosUnmountStatus FileMacos_UnmountDev(char const *bsdDev,
74
 
                                                   Bool wholeDev,
75
 
                                                   Bool eject,
76
 
                                                   Bool su);
77
 
 
78
 
EXTERN void FileMacos_MountDevAsyncNoResult(char const *bsdDev,
 
96
FileMacosUnmountStatus FileMacos_UnmountDev(char const *bsdDev,
 
97
                                            Bool wholeDev,
 
98
                                            Bool eject,
79
99
                                            Bool su);
80
100
 
81
 
EXTERN Bool FileMacos_IsOnExternalDevice(int fd);
82
 
EXTERN Bool FileMacos_IsOnSparseDmg(int fd);
83
 
EXTERN Bool FileMacos_IsSliceDevice(char const *bsdDev);
84
 
 
85
 
EXTERN char *FileMacos_DiskDevToUserFriendlyName(char const *bsdDiskDev);
86
 
 
87
 
EXTERN char *FileMacos_DiskDeviceToUniqueID(char const *bsdPath);
88
 
EXTERN char *FileMacos_UniqueIDToDiskDevice(char const *identifier);
 
101
void FileMacos_MountDevAsyncNoResult(char const *bsdDev,
 
102
                                     Bool su);
 
103
 
 
104
Bool FileMacos_IsOnExternalDevice(int fd);
 
105
Bool FileMacos_IsOnSparseDmg(int fd);
 
106
Bool FileMacos_IsSliceDevice(char const *bsdDev);
 
107
 
 
108
char *FileMacos_DiskDevToUserFriendlyName(char const *bsdDiskDev);
 
109
 
 
110
char *FileMacos_DiskDeviceToUniqueID(char const *bsdPath);
 
111
char *FileMacos_UniqueIDToDiskDevice(char const *identifier);
 
112
 
89
113
#elif defined VMX86_SERVER
90
 
EXTERN int File_GetVMFSBlockSize(ConstUnicode pathName, uint32 *blockSize);
91
 
EXTERN int File_GetVMFSMountInfo(ConstUnicode pathName,
92
 
                                 char **fsType,
93
 
                                 uint32 *version,
94
 
                                 char **remoteIP,
95
 
                                 char **remoteMountPoint,
96
 
                                 char **localMountPoint);
 
114
int File_GetVMFSVersion(ConstUnicode pathName,
 
115
                        uint32 *versionNum);
 
116
int File_GetVMFSBlockSize(ConstUnicode pathName,
 
117
                          uint32 *blockSize);
 
118
 
 
119
int File_GetVMFSMountInfo(ConstUnicode pathName,
 
120
                          char **fsType,
 
121
                          uint32 *version,
 
122
                          char **remoteIP,
 
123
                          char **remoteMountPoint,
 
124
                          char **localMountPoint);
97
125
#endif
98
126
 
99
 
EXTERN Bool File_SupportsZeroedThick(ConstUnicode pathName);
100
 
 
101
 
EXTERN Bool File_Exists(ConstUnicode pathName);
102
 
 
103
 
EXTERN int File_Unlink(ConstUnicode pathName);
104
 
 
105
 
EXTERN int File_UnlinkIfExists(ConstUnicode pathName);
106
 
 
107
 
EXTERN int File_UnlinkDelayed(ConstUnicode pathName);
108
 
 
109
 
EXTERN int File_UnlinkNoFollow(ConstUnicode pathName);
110
 
 
111
 
EXTERN void File_SplitName(ConstUnicode pathName,
112
 
                           Unicode *volume, 
113
 
                           Unicode *dir, 
114
 
                           Unicode *base);
115
 
 
116
 
EXTERN void File_GetPathName(ConstUnicode fullPath, 
117
 
                             Unicode *pathName, 
118
 
                             Unicode *base);
119
 
 
120
 
EXTERN Unicode File_StripSlashes(ConstUnicode path);
121
 
 
122
 
EXTERN Unicode File_PathJoin(ConstUnicode dirName,
123
 
                             ConstUnicode baseName);
124
 
 
125
 
EXTERN Bool File_CreateDirectory(ConstUnicode pathName);
126
 
EXTERN Bool File_EnsureDirectory(ConstUnicode pathName);
127
 
 
128
 
EXTERN Bool File_DeleteEmptyDirectory(ConstUnicode pathName);
129
 
 
130
 
EXTERN Bool File_CreateDirectoryHierarchy(ConstUnicode pathName);
131
 
 
132
 
EXTERN Bool File_DeleteDirectoryTree(ConstUnicode pathName);
133
 
 
134
 
EXTERN int File_ListDirectory(ConstUnicode pathName,
135
 
                              Unicode **ids);
 
127
Bool File_SupportsZeroedThick(ConstUnicode pathName);
 
128
 
 
129
Bool File_SupportsMultiWriter(ConstUnicode pathName);
 
130
 
 
131
Bool File_Exists(ConstUnicode pathName);
 
132
 
 
133
int File_Unlink(ConstUnicode pathName);
 
134
 
 
135
int File_UnlinkIfExists(ConstUnicode pathName);
 
136
 
 
137
int File_UnlinkDelayed(ConstUnicode pathName);
 
138
 
 
139
int File_UnlinkNoFollow(ConstUnicode pathName);
 
140
 
 
141
void File_SplitName(ConstUnicode pathName,
 
142
                    Unicode *volume,
 
143
                    Unicode *dir,
 
144
                    Unicode *base);
 
145
 
 
146
void File_GetPathName(ConstUnicode fullPath,
 
147
                      Unicode *pathName,
 
148
                      Unicode *base);
 
149
 
 
150
Unicode File_StripSlashes(ConstUnicode path);
 
151
 
 
152
Unicode File_PathJoin(ConstUnicode dirName,
 
153
                      ConstUnicode baseName);
 
154
 
 
155
Bool File_CreateDirectory(ConstUnicode pathName);
 
156
Bool File_EnsureDirectory(ConstUnicode pathName);
 
157
 
 
158
Bool File_DeleteEmptyDirectory(ConstUnicode pathName);
 
159
 
 
160
Bool File_CreateDirectoryHierarchy(ConstUnicode pathName);
 
161
 
 
162
Bool File_DeleteDirectoryTree(ConstUnicode pathName);
 
163
 
 
164
int File_ListDirectory(ConstUnicode pathName,
 
165
                       Unicode **ids);
136
166
 
137
167
/*
138
168
 * Simple file-system walk.
139
169
 */
140
170
 
141
 
EXTERN WalkDirContext File_WalkDirectoryStart(ConstUnicode parentPath);
142
 
EXTERN Bool File_WalkDirectoryNext(WalkDirContext context,
143
 
                                   Unicode *path);
144
 
EXTERN void File_WalkDirectoryEnd(WalkDirContext context);
145
 
 
146
 
EXTERN Bool File_IsDirectory(ConstUnicode pathName);
147
 
 
148
 
EXTERN Bool File_IsFile(ConstUnicode pathName);
149
 
 
150
 
EXTERN Bool File_IsSymLink(ConstUnicode fileName);
151
 
 
152
 
EXTERN Bool File_IsCharDevice(ConstUnicode pathName);
153
 
 
154
 
EXTERN Bool File_IsRemote(ConstUnicode pathName);
155
 
 
156
 
EXTERN Bool File_IsEmptyDirectory(ConstUnicode pathName);
157
 
 
158
 
EXTERN Unicode File_Cwd(ConstUnicode drive); // XXX belongs to `process' module
159
 
 
160
 
EXTERN Unicode File_FullPath(ConstUnicode pathName);
161
 
 
162
 
EXTERN Bool File_IsFullPath(ConstUnicode pathName);
163
 
 
164
 
EXTERN uint64 File_GetFreeSpace(ConstUnicode pathName,
165
 
                                Bool doNotAscend);
166
 
 
167
 
EXTERN uint64 File_GetCapacity(ConstUnicode pathName);
 
171
WalkDirContext File_WalkDirectoryStart(ConstUnicode parentPath);
 
172
 
 
173
Bool File_WalkDirectoryNext(WalkDirContext context,
 
174
                            Unicode *path);
 
175
 
 
176
void File_WalkDirectoryEnd(WalkDirContext context);
 
177
 
 
178
Bool File_IsDirectory(ConstUnicode pathName);
 
179
 
 
180
Bool File_IsFile(ConstUnicode pathName);
 
181
 
 
182
Bool File_IsSymLink(ConstUnicode fileName);
 
183
 
 
184
Bool File_IsCharDevice(ConstUnicode pathName);
 
185
 
 
186
Bool File_IsRemote(ConstUnicode pathName);
 
187
 
 
188
Bool File_IsEmptyDirectory(ConstUnicode pathName);
 
189
 
 
190
Unicode File_Cwd(ConstUnicode drive); // XXX belongs to `process' module
 
191
 
 
192
Unicode File_FullPath(ConstUnicode pathName);
 
193
 
 
194
Bool File_IsFullPath(ConstUnicode pathName);
 
195
 
 
196
uint64 File_GetFreeSpace(ConstUnicode pathName,
 
197
                         Bool doNotAscend);
 
198
 
 
199
uint64 File_GetCapacity(ConstUnicode pathName);
168
200
 
169
201
/* Deprecated; use Util_GetSafeTmpDir if you can */
170
 
EXTERN char *File_GetTmpDir(Bool useConf);
 
202
char *File_GetTmpDir(Bool useConf);
171
203
 
172
204
/* Deprecated; use Util_MakeSafeTemp if you can */
173
 
EXTERN int File_MakeTemp(ConstUnicode tag,
174
 
                         Unicode *presult);
175
 
 
176
 
EXTERN int File_MakeTempEx(ConstUnicode dir,
177
 
                           ConstUnicode fileName,
178
 
                           Unicode *presult);
179
 
 
180
 
EXTERN int64 File_GetModTime(ConstUnicode pathName);
181
 
 
182
 
EXTERN char *File_GetModTimeString(ConstUnicode pathName);
183
 
 
184
 
EXTERN char *File_GetUniqueFileSystemID(const char *fileName);
185
 
 
186
 
EXTERN Bool File_GetTimes(ConstUnicode pathName,
187
 
                          VmTimeType *createTime,
188
 
                          VmTimeType *accessTime,
189
 
                          VmTimeType *writeTime,
190
 
                          VmTimeType *attrChangeTime);
191
 
 
192
 
EXTERN Bool File_SetTimes(ConstUnicode pathName,
193
 
                          VmTimeType createTime,
194
 
                          VmTimeType accessTime,
195
 
                          VmTimeType writeTime,
196
 
                          VmTimeType attrChangeTime);
197
 
 
198
 
EXTERN Bool File_GetFilePermissions(ConstUnicode pathName,
199
 
                                   int *mode);
200
 
 
201
 
EXTERN Bool File_SetFilePermissions(ConstUnicode pathName,
202
 
                                    int mode);
203
 
 
204
 
EXTERN Bool File_SupportsFileSize(ConstUnicode pathName,
205
 
                                  uint64 fileSize);
206
 
 
207
 
EXTERN Bool File_SupportsLargeFiles(ConstUnicode pathName);
208
 
 
209
 
EXTERN char *File_MapPathPrefix(const char *oldPath,
210
 
                                const char **oldPrefixes,
211
 
                                const char **newPrefixes,
212
 
                                size_t numPrefixes);
213
 
 
214
 
EXTERN Bool File_CopyFromFdToFd(FileIODescriptor src, 
215
 
                                FileIODescriptor dst);
216
 
 
217
 
EXTERN FileIOResult File_CreatePrompt(FileIODescriptor *file, 
218
 
                                      ConstUnicode pathName, 
219
 
                                      int access, 
220
 
                                      int prompt);
221
 
 
222
 
EXTERN Bool File_CopyFromFd(FileIODescriptor src, 
223
 
                            ConstUnicode dstName, 
224
 
                            Bool overwriteExisting);
225
 
 
226
 
EXTERN Bool File_Copy(ConstUnicode srcName, 
227
 
                      ConstUnicode dstName, 
228
 
                      Bool overwriteExisting);
229
 
 
230
 
EXTERN Bool File_CopyFromFdToName(FileIODescriptor src, 
231
 
                                  ConstUnicode dstName, 
232
 
                                  int dstDispose);
233
 
 
234
 
EXTERN Bool File_CopyFromNameToName(ConstUnicode srcName, 
235
 
                                    ConstUnicode dstName, 
236
 
                                    int dstDispose);
237
 
 
238
 
EXTERN Bool File_Replace(ConstUnicode oldFile, 
239
 
                         ConstUnicode newFile);
240
 
 
241
 
EXTERN Bool File_Rename(ConstUnicode oldFile, 
242
 
                        ConstUnicode newFile);
243
 
 
244
 
EXTERN int64 File_GetSize(ConstUnicode pathName);
245
 
 
246
 
EXTERN int64 File_GetSizeByPath(ConstUnicode pathName);
247
 
 
248
 
EXTERN int64 File_GetSizeAlternate(ConstUnicode pathName);
 
205
int File_MakeTemp(ConstUnicode tag,
 
206
                  Unicode *presult);
 
207
 
 
208
int File_MakeTempEx(ConstUnicode dir,
 
209
                    ConstUnicode fileName,
 
210
                    Unicode *presult);
 
211
 
 
212
int File_MakeTempEx2(ConstUnicode dir,
 
213
                     Bool createTempFile,
 
214
                     File_MakeTempCreateNameFunc *createNameFunc,
 
215
                     void *createFuncData,
 
216
                     Unicode *presult);
 
217
 
 
218
int64 File_GetModTime(ConstUnicode pathName);
 
219
 
 
220
char *File_GetModTimeString(ConstUnicode pathName);
 
221
 
 
222
char *File_GetUniqueFileSystemID(const char *fileName);
 
223
 
 
224
Bool File_GetTimes(ConstUnicode pathName,
 
225
                   VmTimeType *createTime,
 
226
                   VmTimeType *accessTime,
 
227
                   VmTimeType *writeTime,
 
228
                   VmTimeType *attrChangeTime);
 
229
 
 
230
Bool File_SetTimes(ConstUnicode pathName,
 
231
                   VmTimeType createTime,
 
232
                   VmTimeType accessTime,
 
233
                   VmTimeType writeTime,
 
234
                   VmTimeType attrChangeTime);
 
235
 
 
236
Bool File_GetFilePermissions(ConstUnicode pathName,
 
237
                            int *mode);
 
238
 
 
239
Bool File_SetFilePermissions(ConstUnicode pathName,
 
240
                             int mode);
 
241
 
 
242
Bool File_SupportsFileSize(ConstUnicode pathName,
 
243
                           uint64 fileSize);
 
244
 
 
245
Bool File_SupportsLargeFiles(ConstUnicode pathName);
 
246
 
 
247
char *File_MapPathPrefix(const char *oldPath,
 
248
                         const char **oldPrefixes,
 
249
                         const char **newPrefixes,
 
250
                         size_t numPrefixes);
 
251
 
 
252
Bool File_CopyFromFdToFd(FileIODescriptor src,
 
253
                         FileIODescriptor dst);
 
254
 
 
255
FileIOResult File_CreatePrompt(FileIODescriptor *file,
 
256
                               ConstUnicode pathName,
 
257
                               int access,
 
258
                               int prompt);
 
259
 
 
260
Bool File_CopyFromFd(FileIODescriptor src,
 
261
                     ConstUnicode dstName,
 
262
                     Bool overwriteExisting);
 
263
 
 
264
Bool File_Copy(ConstUnicode srcName,
 
265
               ConstUnicode dstName,
 
266
               Bool overwriteExisting);
 
267
 
 
268
Bool File_CopyFromFdToName(FileIODescriptor src,
 
269
                           ConstUnicode dstName,
 
270
                           int dstDispose);
 
271
 
 
272
Bool File_CopyFromNameToName(ConstUnicode srcName,
 
273
                             ConstUnicode dstName,
 
274
                             int dstDispose);
 
275
 
 
276
Bool File_CopyTree(ConstUnicode srcName,
 
277
                   ConstUnicode dstName,
 
278
                   Bool overwriteExisting,
 
279
                   Bool followSymlinks);
 
280
 
 
281
Bool File_Replace(ConstUnicode oldFile,
 
282
                  ConstUnicode newFile);
 
283
 
 
284
Bool File_Move(ConstUnicode oldFile,
 
285
               ConstUnicode newFile,
 
286
               Bool *asRename);
 
287
 
 
288
void File_Rotate(const char *fileName,
 
289
                 int n,
 
290
                 Bool noRename,
 
291
                 char **newFileName);
 
292
 
 
293
/* Get size only for regular file. */
 
294
int64 File_GetSize(ConstUnicode pathName);
 
295
 
 
296
/* Get size for file or directory. */
 
297
int64 File_GetSizeEx(ConstUnicode pathName);
 
298
 
 
299
int64 File_GetSizeByPath(ConstUnicode pathName);
 
300
 
 
301
int64 File_GetSizeAlternate(ConstUnicode pathName);
249
302
 
250
303
/* file change notification module */
251
304
typedef void (*CbFunction)(void *clientData);
252
305
 
253
 
typedef void (*NotifyCallback)(ConstUnicode pathName, 
254
 
                               int err, 
 
306
typedef void (*NotifyCallback)(ConstUnicode pathName,
 
307
                               int err,
255
308
                               void *data);
256
309
 
257
310
typedef void (*PollTimeout) (CbFunction f,
261
314
typedef void (*PollRemoveTimeout) (CbFunction f,
262
315
                                   void *clientData);
263
316
 
264
 
EXTERN void File_PollInit(PollTimeout pt, 
265
 
                          PollRemoveTimeout prt);
266
 
 
267
 
EXTERN void File_PollExit(void);
268
 
 
269
 
EXTERN void File_PollImpersonateOnCheck(Bool check);
270
 
 
271
 
EXTERN Bool File_PollAddFile(ConstUnicode pathName, 
272
 
                             uint32 pollPeriod, 
273
 
                             NotifyCallback callback, 
274
 
                             void *data, 
275
 
                             Bool fPeriodic);
276
 
 
277
 
EXTERN Bool File_PollAddDirFile(ConstUnicode pathName,
278
 
                                uint32 pollPeriod, 
279
 
                                NotifyCallback callback,
280
 
                                void *data, 
281
 
                                Bool fPeriodic);
282
 
 
283
 
EXTERN Bool File_PollRemoveFile(ConstUnicode pathName, 
284
 
                                uint32 pollPeriod,
285
 
                                NotifyCallback callback);
286
 
 
287
 
EXTERN Bool File_IsSameFile(ConstUnicode path1,
288
 
                            ConstUnicode path2);
289
 
 
290
 
EXTERN char *File_PrependToPath(const char *searchPath,
291
 
                                const char *elem);
292
 
 
293
 
EXTERN Bool File_FindFileInSearchPath(const char *file,
294
 
                                      const char *searchPath,
295
 
                                      const char *cwd,
296
 
                                      char **result);
297
 
 
298
 
EXTERN Unicode File_ReplaceExtension(ConstUnicode pathName,
299
 
                                     ConstUnicode newExtension,
300
 
                                     uint32 numExtensions,
301
 
                                     ...);
302
 
 
303
 
EXTERN Bool File_MakeCfgFileExecutable(ConstUnicode pathName);
304
 
 
305
 
EXTERN char *File_ExpandAndCheckDir(const char *dirName);
 
317
void File_PollInit(PollTimeout pt,
 
318
                   PollRemoveTimeout prt);
 
319
 
 
320
void File_PollExit(void);
 
321
 
 
322
void File_PollImpersonateOnCheck(Bool check);
 
323
 
 
324
Bool File_PollAddFile(ConstUnicode pathName,
 
325
                      uint32 pollPeriod,
 
326
                      NotifyCallback callback,
 
327
                      void *data,
 
328
                      Bool fPeriodic);
 
329
 
 
330
Bool File_PollAddDirFile(ConstUnicode pathName,
 
331
                         uint32 pollPeriod,
 
332
                         NotifyCallback callback,
 
333
                         void *data,
 
334
                         Bool fPeriodic);
 
335
 
 
336
Bool File_PollRemoveFile(ConstUnicode pathName,
 
337
                         uint32 pollPeriod,
 
338
                         NotifyCallback callback);
 
339
 
 
340
Bool File_IsSameFile(ConstUnicode path1,
 
341
                     ConstUnicode path2);
 
342
 
 
343
char *File_PrependToPath(const char *searchPath,
 
344
                         const char *elem);
 
345
 
 
346
Bool File_FindFileInSearchPath(const char *file,
 
347
                               const char *searchPath,
 
348
                               const char *cwd,
 
349
                               char **result);
 
350
 
 
351
Unicode File_ReplaceExtension(ConstUnicode pathName,
 
352
                              ConstUnicode newExtension,
 
353
                              uint32 numExtensions,
 
354
                              ...);
 
355
 
 
356
Unicode File_RemoveExtension(ConstUnicode pathName);
 
357
 
 
358
Bool File_MakeCfgFileExecutable(ConstUnicode pathName);
 
359
 
 
360
char *File_ExpandAndCheckDir(const char *dirName);
306
361
 
307
362
#ifdef __cplusplus
308
363
} // extern "C" {