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

« back to all changes in this revision

Viewing changes to lib/file/fileLockPosix.c

  • 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:
1054
1054
 *----------------------------------------------------------------------
1055
1055
 */
1056
1056
 
1057
 
void *
 
1057
FileLockToken *
1058
1058
FileLock_Lock(ConstUnicode filePath,         // IN:
1059
1059
              const Bool readOnly,           // IN:
1060
1060
              const uint32 msecMaxWaitTime,  // IN:
1061
1061
              int *err)                      // OUT:
1062
1062
{
1063
 
   void *lockToken;
1064
1063
   Unicode normalizedPath;
 
1064
   FileLockToken *tokenPtr;
1065
1065
 
1066
1066
   ASSERT(filePath);
1067
1067
   ASSERT(err);
1070
1070
   if (normalizedPath == NULL) {
1071
1071
      *err = EINVAL;
1072
1072
 
1073
 
      lockToken = NULL;
 
1073
      tokenPtr = NULL;
1074
1074
   } else {
1075
1075
      char creationTimeString[32];
1076
1076
 
1077
1077
      Str_Sprintf(creationTimeString, sizeof creationTimeString, "%"FMT64"u",
1078
1078
                  ProcessCreationTime(getpid()));
1079
1079
 
1080
 
      lockToken = FileLockIntrinsic(normalizedPath, !readOnly, msecMaxWaitTime,
1081
 
                                    creationTimeString, err);
 
1080
      tokenPtr = FileLockIntrinsic(normalizedPath, !readOnly, msecMaxWaitTime,
 
1081
                                   creationTimeString, err);
1082
1082
 
1083
1083
      Unicode_Free(normalizedPath);
1084
1084
   }
1085
1085
 
1086
 
   return lockToken;
 
1086
   return tokenPtr;
1087
1087
}
1088
1088
 
1089
1089
 
1148
1148
 */
1149
1149
 
1150
1150
int
1151
 
FileLock_Unlock(ConstUnicode filePath,  // IN:
1152
 
                const void *lockToken)  // IN:
 
1151
FileLock_Unlock(const FileLockToken *lockToken)  // IN:
1153
1152
{
1154
 
   int err;
1155
 
   Unicode normalizedPath;
1156
 
 
1157
 
   ASSERT(filePath);
1158
1153
   ASSERT(lockToken);
1159
1154
 
1160
 
   normalizedPath = FileLockNormalizePath(filePath);
1161
 
   if (normalizedPath == NULL) {
1162
 
      err = EINVAL;
1163
 
   } else {
1164
 
      err = FileUnlockIntrinsic(normalizedPath, lockToken);
1165
 
 
1166
 
      Unicode_Free(normalizedPath);
1167
 
   }
1168
 
 
1169
 
   return err;
1170
 
}
1171
 
 
1172
 
 
1173
 
/*
1174
 
 *----------------------------------------------------------------------
1175
 
 *
1176
 
 * FileLock_DeleteFileVMX --
1177
 
 *
1178
 
 *      The VMX file delete primitive.
1179
 
 *
1180
 
 * Results:
1181
 
 *      0       unlocked
1182
 
 *      >0      errno
1183
 
 *
1184
 
 * Side effects:
1185
 
 *      Changes the host file system.
1186
 
 *
1187
 
 * Note:
1188
 
 *      THIS IS A HORRIBLE HACK AND NEEDS TO BE REMOVED ASAP!!!
1189
 
 *
1190
 
 *----------------------------------------------------------------------
1191
 
 */
1192
 
 
1193
 
int
1194
 
FileLock_DeleteFileVMX(ConstUnicode filePath)  // IN:
1195
 
{
1196
 
   int err;
1197
 
   Unicode normalizedPath;
1198
 
 
1199
 
   ASSERT(filePath);
1200
 
 
1201
 
   normalizedPath = FileLockNormalizePath(filePath);
1202
 
   if (normalizedPath == NULL) {
1203
 
      err = EINVAL;
1204
 
   } else {
1205
 
      err = FileLockHackVMX(normalizedPath);
1206
 
 
1207
 
      Unicode_Free(normalizedPath);
1208
 
   }
1209
 
 
1210
 
   return err;
 
1155
   return FileUnlockIntrinsic((FileLockToken *) lockToken);
1211
1156
}
1212
1157
 
1213
1158
#else