Bool *timesChanged);
static HgfsInternalStatus HgfsGetHiddenXAttr(char const *fileName, Bool *attribute);
-static HgfsInternalStatus HgfsSetHiddenXAttr(char const *fileName, Bool value);
+static HgfsInternalStatus HgfsSetHiddenXAttr(char const *fileName,
+ Bool value,
+ mode_t permissions);
static HgfsInternalStatus HgfsEffectivePermissions(char *fileName,
Bool readOnlyShare,
uint32 *permissions);
goto exit;
}
- /* Set the rest of the Windows specific attributes if necessary. */
- if (needToSetAttribute) {
- HgfsSetHiddenXAttr(openInfo->utf8Name, openInfo->attr & HGFS_ATTR_HIDDEN);
- }
-
/* Stat file to get its volume and file info */
if (fstat(fd, &fileStat) < 0) {
error = errno;
goto exit;
}
+ /* Set the rest of the Windows specific attributes if necessary. */
+ if (needToSetAttribute) {
+ HgfsSetHiddenXAttr(openInfo->utf8Name, openInfo->attr & HGFS_ATTR_HIDDEN,
+ fileStat.st_mode);
+ }
+
/* Try to acquire an oplock. */
if (openInfo->mask & HGFS_OPEN_VALID_SERVER_LOCK) {
serverLock = openInfo->desiredLock;
}
}
- if (attr->mask & HGFS_ATTR_VALID_FLAGS) {
+ /* Setting hidden attribute for symlink itself is not supported. */
+ if ((attr->mask & HGFS_ATTR_VALID_FLAGS) && !S_ISLNK(statBuf.st_mode)) {
char *localName;
size_t localNameSize;
if (HgfsHandle2FileName(file, session, &localName, &localNameSize)) {
- status = HgfsSetHiddenXAttr(localName, attr->flags & HGFS_ATTR_HIDDEN);
+ status = HgfsSetHiddenXAttr(localName, attr->flags & HGFS_ATTR_HIDDEN,
+ newPermissions);
free(localName);
}
}
}
if (attr->mask & HGFS_ATTR_VALID_FLAGS) {
- status = HgfsSetHiddenXAttr(localName, attr->flags & HGFS_ATTR_HIDDEN);
+ status = HgfsSetHiddenXAttr(localName, attr->flags & HGFS_ATTR_HIDDEN,
+ newPermissions);
}
timesStatus = HgfsSetattrTimes(&statBuf, attr, hints,
* Set hidden attribute when requested.
* Do not fail directory creation if setting hidden attribute fails.
*/
- HgfsSetHiddenXAttr(utf8Name, TRUE);
+ HgfsSetHiddenXAttr(utf8Name, TRUE, permissions);
}
if (status) {
static HgfsInternalStatus
HgfsSetHiddenXAttr(char const *fileName, // IN: path to the file
- Bool value) // IN: new value to the invisible attribute
+ Bool value, // IN: new value to the invisible attribute
+ mode_t permissions) // IN: permissions of the file
{
HgfsInternalStatus err;
Bool changed = FALSE;
attrList.commonattr = ATTR_CMN_FNDRINFO;
err = setattrlist(fileName, &attrList, attrBuf.finderInfo,
sizeof attrBuf.finderInfo, 0);
+ if (0 != err) {
+ err = errno;
+ }
+ if (EACCES == err) {
+ mode_t mode = permissions | S_IWOTH | S_IWGRP | S_IWUSR;
+ if (chmod(fileName, mode) == 0) {
+ err = setattrlist(fileName, &attrList, attrBuf.finderInfo,
+ sizeof attrBuf.finderInfo, 0);
+ if (0 != err) {
+ err = errno;
+ }
+ chmod(fileName, permissions);
+ } else {
+ err = errno;
+ }
+ }
}
return err;
}
static HgfsInternalStatus
HgfsSetHiddenXAttr(char const *fileName, // IN: File name
- Bool value) // IN: Value of the attribute to set
+ Bool value, // IN: Value of the attribute to set
+ mode_t permissions) // IN: permissions of the file
{
return 0;
}