Opened 16 years ago
Closed 13 years ago
#205 closed defect (fixed)
coreutils chmod does not work on files without EA
Reported by: | Yuri Dario | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.5 |
Component: | libc-backend | Version: | 0.6.2 |
Severity: | normal | Keywords: | chmod MODE EA |
Cc: |
Description
The coreutils chmod.exe does not modify the mode attribute if MODE EA is not present in the file.
The attached patch fixes two problems in chmod():
1) libc_back_fsUnixAttribsGetMode returns -ENOTSUP when EA are not supported by file system and EA are not present on file. Probably the two error conditions should be split, but in this case we can go on even if EA are not supported, we will fail in the DosSetPathInfo call.
2) the MODE field contains also the bits to specify the kind of handle (dir, file, socket, ...) and these bits are not initialized, so when MODE is read back it is reported as zero. This bit is handled inside the backend function, I don't know if it must be handled before reaching the final steps.
Index: src/lib/sys/b_fsNativeFileModeSet.c =================================================================== --- src/lib/sys/b_fsNativeFileModeSet.c (revision 3650) +++ src/lib/sys/b_fsNativeFileModeSet.c (working copy) @@ -50,7 +50,7 @@ * * @returns 0 on success. * @returns Negative error code (errno.h) on failure. - * @param fh Handle to file. + * @param pszNativePath Path to the file to change. * @param Mode The filemode. */ int __libc_back_fsNativeFileModeSet(const char *pszNativePath, mode_t Mode) @@ -160,12 +160,25 @@ { mode_t CurMode; rc = __libc_back_fsUnixAttribsGetMode(-1, pszNativePath, &CurMode); - if (__predict_true(!rc)) + // YD -ENOTSUP is returned if EA not supported or not present! + // in the latter case, we need to continue + if (__predict_true(!rc) || rc==-ENOTSUP) { /* correct the passed in Mode mask. */ Mode &= ALLPERMS; /** @todo sticky bit and set uid/gid access validation... */ Mode |= CurMode & ~ALLPERMS; +#if OFF_MAX > LONG_MAX + ULONG fAttributtes = fLarge ? info.fsts4L.attrFile : info.fsts4.attrFile; +#else + ULONG fAttributtes = info.fsts4.attrFile; +#endif + + if (fAttributtes & FILE_DIRECTORY) + Mode |= S_IFDIR; + else + Mode |= S_IFREG; + /* construct FEA2 stuff. */ #pragma pack(1) struct __LIBC_FSUNIXATTRIBSSETMODE
Change History (2)
comment:1 by , 14 years ago
Status: | new → assigned |
---|
comment:2 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Implemented in r3777.