diff options
author | Ron Yorston <rmy@pobox.com> | 2015-03-25 14:16:45 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-03-25 14:16:45 +0000 |
commit | f030c24257d48c71fd11eb2bc4c00224d2970d34 (patch) | |
tree | 923bc8828cc0abeeb284f8cc96f9a54bffe2e425 /win32/mingw.c | |
parent | 15efec6ad51f5292a5f4d7b314219125d69e9acb (diff) | |
download | busybox-w32-f030c24257d48c71fd11eb2bc4c00224d2970d34.tar.gz busybox-w32-f030c24257d48c71fd11eb2bc4c00224d2970d34.tar.bz2 busybox-w32-f030c24257d48c71fd11eb2bc4c00224d2970d34.zip |
mingw: changes to handling of directory permissions
The read-only attribute on a directory in Microsoft Windows is
quite different from write permission in POSIX. Modify rmdir(2)
and chmod(2) to provide more POSIX-like behaviour:
rmdir will remove a directory even if it's read-only
chmod won't make a directory read-only
Diffstat (limited to 'win32/mingw.c')
-rw-r--r-- | win32/mingw.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index fe45589c2..d76f17820 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -842,6 +842,19 @@ int mingw_mkdir(const char *path, int mode UNUSED_PARAM) | |||
842 | return ret; | 842 | return ret; |
843 | } | 843 | } |
844 | 844 | ||
845 | #undef chmod | ||
846 | int mingw_chmod(const char *path, int mode) | ||
847 | { | ||
848 | WIN32_FILE_ATTRIBUTE_DATA fdata; | ||
849 | |||
850 | if ( get_file_attr(path, &fdata) == 0 && | ||
851 | fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { | ||
852 | mode |= 0222; | ||
853 | } | ||
854 | |||
855 | return chmod(path, mode); | ||
856 | } | ||
857 | |||
845 | int fcntl(int fd, int cmd, ...) | 858 | int fcntl(int fd, int cmd, ...) |
846 | { | 859 | { |
847 | va_list arg; | 860 | va_list arg; |
@@ -1014,6 +1027,14 @@ int mingw_access(const char *name, int mode) | |||
1014 | return -1; | 1027 | return -1; |
1015 | } | 1028 | } |
1016 | 1029 | ||
1030 | #undef rmdir | ||
1031 | int mingw_rmdir(const char *path) | ||
1032 | { | ||
1033 | /* read-only directories cannot be removed */ | ||
1034 | chmod(path, 0666); | ||
1035 | return rmdir(path); | ||
1036 | } | ||
1037 | |||
1017 | /* check if path can be made into an executable by adding a suffix; | 1038 | /* check if path can be made into an executable by adding a suffix; |
1018 | * return an allocated string containing the path if it can; | 1039 | * return an allocated string containing the path if it can; |
1019 | * return NULL if not. | 1040 | * return NULL if not. |