mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-26 07:25:25 +02:00
3-6 C8
This commit is contained in:
parent
ed0888d6c2
commit
277435f8f2
@ -487,10 +487,7 @@ fileio_write(struct w32_io* pio, const void *buf, unsigned int max) {
|
|||||||
|
|
||||||
/* fstat() implemetation */
|
/* fstat() implemetation */
|
||||||
int
|
int
|
||||||
fileio_fstat(struct w32_io* pio, struct stat *buf) {
|
fileio_fstat(struct w32_io* pio, struct _stat64 *buf) {
|
||||||
|
|
||||||
errno = ENOTSUP;
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
int fd = _open_osfhandle((intptr_t)pio->handle, 0);
|
int fd = _open_osfhandle((intptr_t)pio->handle, 0);
|
||||||
debug2("pio:%p", pio);
|
debug2("pio:%p", pio);
|
||||||
@ -499,13 +496,18 @@ fileio_fstat(struct w32_io* pio, struct stat *buf) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _fstat(fd, (struct _stat*)&buf);
|
return _fstat64(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* isatty() implementation */
|
/* isatty() implementation */
|
||||||
int
|
int
|
||||||
fileio_isatty(struct w32_io* pio) {
|
fileio_isatty(struct w32_io* pio) {
|
||||||
return (GetFileType(pio->handle) == FILE_TYPE_CHAR) ? TRUE : FALSE;
|
if (GetFileType(pio->handle) == FILE_TYPE_CHAR)
|
||||||
|
return 1;
|
||||||
|
else {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fdopen implementation */
|
/* fdopen implementation */
|
||||||
|
43
contrib/win32/win32compat/inc/sys/stat.h
Normal file
43
contrib/win32/win32compat/inc/sys/stat.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Author: Manoj Ampalam <manoj.ampalam@microsoft.com>
|
||||||
|
*
|
||||||
|
* private stat.h (all code relying on POSIX wrapper should include this version
|
||||||
|
* instead of the one in Windows SDK.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* flags COPIED FROM STAT.H
|
||||||
|
*/
|
||||||
|
#define _S_IFMT 0xF000 // File type mask
|
||||||
|
#define _S_IFDIR 0x4000 // Directory
|
||||||
|
#define _S_IFCHR 0x2000 // Character special
|
||||||
|
#define _S_IFIFO 0x1000 // Pipe
|
||||||
|
#define _S_IFREG 0x8000 // Regular
|
||||||
|
#define _S_IREAD 0x0100 // Read permission, owner
|
||||||
|
#define _S_IWRITE 0x0080 // Write permission, owner
|
||||||
|
#define _S_IEXEC 0x0040 // Execute/search permission, owner
|
||||||
|
|
||||||
|
|
||||||
|
#define S_IFMT _S_IFMT
|
||||||
|
#define S_IFDIR _S_IFDIR
|
||||||
|
#define S_IFCHR _S_IFCHR
|
||||||
|
#define S_IFREG _S_IFREG
|
||||||
|
#define S_IREAD _S_IREAD
|
||||||
|
#define S_IWRITE _S_IWRITE
|
||||||
|
#define S_IEXEC _S_IEXEC
|
||||||
|
|
||||||
|
#define stat w32_stat
|
||||||
|
|
||||||
|
struct w32_stat {
|
||||||
|
dev_t st_dev; /* ID of device containing file */
|
||||||
|
ino_t st_ino; /* inode number */
|
||||||
|
unsigned short st_mode; /* protection */
|
||||||
|
short st_nlink; /* number of hard links */
|
||||||
|
short st_uid; /* user ID of owner */
|
||||||
|
short st_gid; /* group ID of owner */
|
||||||
|
dev_t st_rdev; /* device ID (if special file) */
|
||||||
|
__int64 st_size; /* total size, in bytes */
|
||||||
|
__int64 st_atime; /* time of last access */
|
||||||
|
__int64 st_mtime; /* time of last modification */
|
||||||
|
__int64 st_ctime; /* time of last status change */
|
||||||
|
};
|
@ -45,7 +45,7 @@ int w32_pipe(int *pfds);
|
|||||||
int w32_open(const char *pathname, int flags, ...);
|
int w32_open(const char *pathname, int flags, ...);
|
||||||
int w32_read(int fd, void *dst, unsigned int max);
|
int w32_read(int fd, void *dst, unsigned int max);
|
||||||
int w32_write(int fd, const void *buf, unsigned int max);
|
int w32_write(int fd, const void *buf, unsigned int max);
|
||||||
int w32_fstat(int fd, struct stat *buf);
|
int w32_fstat(int fd, struct w32_stat *buf);
|
||||||
int w32_isatty(int fd);
|
int w32_isatty(int fd);
|
||||||
FILE* w32_fdopen(int fd, const char *mode);
|
FILE* w32_fdopen(int fd, const char *mode);
|
||||||
|
|
||||||
|
@ -344,14 +344,17 @@ w32_write(int fd, const void *buf, unsigned int max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
w32_fstat(int fd, struct stat *buf) {
|
w32_fstat(int fd, struct w32_stat *buf) {
|
||||||
CHECK_FD(fd);
|
CHECK_FD(fd);
|
||||||
return fileio_fstat(fd_table.w32_ios[fd], buf);
|
return fileio_fstat(fd_table.w32_ios[fd], (struct _stat64*)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
w32_isatty(int fd) {
|
w32_isatty(int fd) {
|
||||||
CHECK_FD(fd);
|
if ((fd < 0) || (fd > MAX_FDS - 1) || fd_table.w32_ios[fd] == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return fileio_isatty(fd_table.w32_ios[fd]);
|
return fileio_isatty(fd_table.w32_ios[fd]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ int fileio_pipe(struct w32_io* pio[2]);
|
|||||||
struct w32_io* fileio_open(const char *pathname, int flags, int mode);
|
struct w32_io* fileio_open(const char *pathname, int flags, int mode);
|
||||||
int fileio_read(struct w32_io* pio, void *dst, unsigned int max);
|
int fileio_read(struct w32_io* pio, void *dst, unsigned int max);
|
||||||
int fileio_write(struct w32_io* pio, const void *buf, unsigned int max);
|
int fileio_write(struct w32_io* pio, const void *buf, unsigned int max);
|
||||||
int fileio_fstat(struct w32_io* pio, struct stat *buf);
|
int fileio_fstat(struct w32_io* pio, struct _stat64 *buf);
|
||||||
int fileio_isatty(struct w32_io* pio);
|
int fileio_isatty(struct w32_io* pio);
|
||||||
FILE* fileio_fdopen(struct w32_io* pio, const char *mode);
|
FILE* fileio_fdopen(struct w32_io* pio, const char *mode);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user