aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2008-04-05 14:32:28 +0000
committerEli Zaretskii2008-04-05 14:32:28 +0000
commite3b88685f93b51ca2752fd47ef38e5a75de1f395 (patch)
tree69da9e45ff019c474650ee36207171b3973e83d6 /src
parente058f331f553cdd55ed4bb8e0270e0bef40de7c5 (diff)
downloademacs-e3b88685f93b51ca2752fd47ef38e5a75de1f395.tar.gz
emacs-e3b88685f93b51ca2752fd47ef38e5a75de1f395.zip
(sys_chown, stat, fstat): Use S_* constants instead of _S_* ones, since we
now use our own sys/stat.h. (stat, fstat): Don't mangle the inode number.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/w32.c b/src/w32.c
index 24921687c9e..cfb11b9cd96 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2119,7 +2119,7 @@ sys_chmod (const char * path, int mode)
2119int 2119int
2120sys_chown (const char *path, uid_t owner, gid_t group) 2120sys_chown (const char *path, uid_t owner, gid_t group)
2121{ 2121{
2122 if (sys_chmod (path, _S_IREAD) == -1) /* check if file exists */ 2122 if (sys_chmod (path, S_IREAD) == -1) /* check if file exists */
2123 return -1; 2123 return -1;
2124 return 0; 2124 return 0;
2125} 2125}
@@ -2526,7 +2526,7 @@ stat (const char * path, struct stat * buf)
2526 char *name, *r; 2526 char *name, *r;
2527 WIN32_FIND_DATA wfd; 2527 WIN32_FIND_DATA wfd;
2528 HANDLE fh; 2528 HANDLE fh;
2529 DWORD fake_inode; 2529 unsigned __int64 fake_inode;
2530 int permission; 2530 int permission;
2531 int len; 2531 int len;
2532 int rootdir = FALSE; 2532 int rootdir = FALSE;
@@ -2646,7 +2646,9 @@ stat (const char * path, struct stat * buf)
2646 all the time (even then there are situations where it is 2646 all the time (even then there are situations where it is
2647 not unique). Reputedly, there are at most 48 bits of info 2647 not unique). Reputedly, there are at most 48 bits of info
2648 (on NTFS, presumably less on FAT). */ 2648 (on NTFS, presumably less on FAT). */
2649 fake_inode = info.nFileIndexLow ^ info.nFileIndexHigh; 2649 fake_inode = info.nFileIndexHigh;
2650 fake_inode <<= 32;
2651 fake_inode += info.nFileIndexLow;
2650 } 2652 }
2651 else 2653 else
2652 { 2654 {
@@ -2656,22 +2658,22 @@ stat (const char * path, struct stat * buf)
2656 2658
2657 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 2659 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2658 { 2660 {
2659 buf->st_mode = _S_IFDIR; 2661 buf->st_mode = S_IFDIR;
2660 } 2662 }
2661 else 2663 else
2662 { 2664 {
2663 switch (GetFileType (fh)) 2665 switch (GetFileType (fh))
2664 { 2666 {
2665 case FILE_TYPE_DISK: 2667 case FILE_TYPE_DISK:
2666 buf->st_mode = _S_IFREG; 2668 buf->st_mode = S_IFREG;
2667 break; 2669 break;
2668 case FILE_TYPE_PIPE: 2670 case FILE_TYPE_PIPE:
2669 buf->st_mode = _S_IFIFO; 2671 buf->st_mode = S_IFIFO;
2670 break; 2672 break;
2671 case FILE_TYPE_CHAR: 2673 case FILE_TYPE_CHAR:
2672 case FILE_TYPE_UNKNOWN: 2674 case FILE_TYPE_UNKNOWN:
2673 default: 2675 default:
2674 buf->st_mode = _S_IFCHR; 2676 buf->st_mode = S_IFCHR;
2675 } 2677 }
2676 } 2678 }
2677 CloseHandle (fh); 2679 CloseHandle (fh);
@@ -2680,7 +2682,7 @@ stat (const char * path, struct stat * buf)
2680 { 2682 {
2681 /* Don't bother to make this information more accurate. */ 2683 /* Don't bother to make this information more accurate. */
2682 buf->st_mode = (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? 2684 buf->st_mode = (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ?
2683 _S_IFDIR : _S_IFREG; 2685 S_IFDIR : S_IFREG;
2684 buf->st_nlink = 1; 2686 buf->st_nlink = 1;
2685 fake_inode = 0; 2687 fake_inode = 0;
2686 } 2688 }
@@ -2723,14 +2725,14 @@ stat (const char * path, struct stat * buf)
2723 2725
2724 /* determine rwx permissions */ 2726 /* determine rwx permissions */
2725 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) 2727 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
2726 permission = _S_IREAD; 2728 permission = S_IREAD;
2727 else 2729 else
2728 permission = _S_IREAD | _S_IWRITE; 2730 permission = S_IREAD | S_IWRITE;
2729 2731
2730 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 2732 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2731 permission |= _S_IEXEC; 2733 permission |= S_IEXEC;
2732 else if (is_exec (name)) 2734 else if (is_exec (name))
2733 permission |= _S_IEXEC; 2735 permission |= S_IEXEC;
2734 2736
2735 buf->st_mode |= permission | (permission >> 3) | (permission >> 6); 2737 buf->st_mode |= permission | (permission >> 3) | (permission >> 6);
2736 2738
@@ -2744,13 +2746,13 @@ fstat (int desc, struct stat * buf)
2744{ 2746{
2745 HANDLE fh = (HANDLE) _get_osfhandle (desc); 2747 HANDLE fh = (HANDLE) _get_osfhandle (desc);
2746 BY_HANDLE_FILE_INFORMATION info; 2748 BY_HANDLE_FILE_INFORMATION info;
2747 DWORD fake_inode; 2749 unsigned __int64 fake_inode;
2748 int permission; 2750 int permission;
2749 2751
2750 switch (GetFileType (fh) & ~FILE_TYPE_REMOTE) 2752 switch (GetFileType (fh) & ~FILE_TYPE_REMOTE)
2751 { 2753 {
2752 case FILE_TYPE_DISK: 2754 case FILE_TYPE_DISK:
2753 buf->st_mode = _S_IFREG; 2755 buf->st_mode = S_IFREG;
2754 if (!GetFileInformationByHandle (fh, &info)) 2756 if (!GetFileInformationByHandle (fh, &info))
2755 { 2757 {
2756 errno = EACCES; 2758 errno = EACCES;
@@ -2758,12 +2760,12 @@ fstat (int desc, struct stat * buf)
2758 } 2760 }
2759 break; 2761 break;
2760 case FILE_TYPE_PIPE: 2762 case FILE_TYPE_PIPE:
2761 buf->st_mode = _S_IFIFO; 2763 buf->st_mode = S_IFIFO;
2762 goto non_disk; 2764 goto non_disk;
2763 case FILE_TYPE_CHAR: 2765 case FILE_TYPE_CHAR:
2764 case FILE_TYPE_UNKNOWN: 2766 case FILE_TYPE_UNKNOWN:
2765 default: 2767 default:
2766 buf->st_mode = _S_IFCHR; 2768 buf->st_mode = S_IFCHR;
2767 non_disk: 2769 non_disk:
2768 memset (&info, 0, sizeof (info)); 2770 memset (&info, 0, sizeof (info));
2769 info.dwFileAttributes = 0; 2771 info.dwFileAttributes = 0;
@@ -2773,7 +2775,7 @@ fstat (int desc, struct stat * buf)
2773 } 2775 }
2774 2776
2775 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 2777 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2776 buf->st_mode = _S_IFDIR; 2778 buf->st_mode = S_IFDIR;
2777 2779
2778 buf->st_nlink = info.nNumberOfLinks; 2780 buf->st_nlink = info.nNumberOfLinks;
2779 /* Might as well use file index to fake inode values, but this 2781 /* Might as well use file index to fake inode values, but this
@@ -2781,7 +2783,9 @@ fstat (int desc, struct stat * buf)
2781 all the time (even then there are situations where it is 2783 all the time (even then there are situations where it is
2782 not unique). Reputedly, there are at most 48 bits of info 2784 not unique). Reputedly, there are at most 48 bits of info
2783 (on NTFS, presumably less on FAT). */ 2785 (on NTFS, presumably less on FAT). */
2784 fake_inode = info.nFileIndexLow ^ info.nFileIndexHigh; 2786 fake_inode = info.nFileIndexHigh;
2787 fake_inode <<= 32;
2788 fake_inode += info.nFileIndexLow;
2785 2789
2786 /* MSVC defines _ino_t to be short; other libc's might not. */ 2790 /* MSVC defines _ino_t to be short; other libc's might not. */
2787 if (sizeof (buf->st_ino) == 2) 2791 if (sizeof (buf->st_ino) == 2)
@@ -2807,12 +2811,12 @@ fstat (int desc, struct stat * buf)
2807 2811
2808 /* determine rwx permissions */ 2812 /* determine rwx permissions */
2809 if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) 2813 if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
2810 permission = _S_IREAD; 2814 permission = S_IREAD;
2811 else 2815 else
2812 permission = _S_IREAD | _S_IWRITE; 2816 permission = S_IREAD | S_IWRITE;
2813 2817
2814 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 2818 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2815 permission |= _S_IEXEC; 2819 permission |= S_IEXEC;
2816 else 2820 else
2817 { 2821 {
2818#if 0 /* no way of knowing the filename */ 2822#if 0 /* no way of knowing the filename */
@@ -2822,7 +2826,7 @@ fstat (int desc, struct stat * buf)
2822 stricmp (p, ".com") == 0 || 2826 stricmp (p, ".com") == 0 ||
2823 stricmp (p, ".bat") == 0 || 2827 stricmp (p, ".bat") == 0 ||
2824 stricmp (p, ".cmd") == 0)) 2828 stricmp (p, ".cmd") == 0))
2825 permission |= _S_IEXEC; 2829 permission |= S_IEXEC;
2826#endif 2830#endif
2827 } 2831 }
2828 2832