Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1584 isblank, stat64 and fstat64

WSL
pending
Earnie Boyd
None
Task
later
Feature_in_WSL_4.1
True
2013-02-19
2011-10-07
Anonymous
No

The patch does:
- Make sure the C99 isblank is defined the same way as iswblank so we can use
std::tr1::isblank in C++ when "-ansi" is used.
- Add support for stat64 and fstat64 for better LFS and POSIX compatibility.

This patch is applied for MinGW Runtime 3.20.

Test case for stat64:

#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
struct stat64 sb = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#if __MSVCRT_VERSION__ < 0x601
time_t st_ctime = 0, st_atime = 0, st_mtime = 0;
#endif
if (argc != 2) {
fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
exit(EXIT_FAILURE);
}

if (stat64(argv[1], &sb) == -1) {
perror("stat64");
exit(EXIT_FAILURE);
}

printf("File type: ");
switch (sb.st_mode & S_IFMT) {
case S_IFBLK: printf("block device\n"); break;
case S_IFCHR: printf("character device\n"); break;
case S_IFDIR: printf("directory\n"); break;
case S_IFIFO: printf("FIFO/pipe\n"); break;
case S_IFREG: printf("regular file\n"); break;
default: printf("unknown?\n"); break;
}

printf("I-node number: %ld\n", (long) sb.st_ino);

printf("Mode: %lo (octal)\n",
(unsigned long) sb.st_mode);

printf("Link count: %ld\n", (long) sb.st_nlink);
printf("Ownership: UID=%ld GID=%ld\n",
(long) sb.st_uid, (long) sb.st_gid);

printf("File size: %I64d bytes\n",
(long long) sb.st_size);

#if __MSVCRT_VERSION__ >= 0x601
printf("Creation time: %s", _ctime64(&sb.st_ctime));
printf("Last file access: %s", _ctime64(&sb.st_atime));
printf("Last file modification: %s", _ctime64(&sb.st_mtime));
#else
st_ctime = (time_t)(sb.st_ctime);
st_atime = (time_t)(sb.st_atime);
st_mtime = (time_t)(sb.st_mtime);
printf("Creation time: %s", ctime(&st_ctime));
printf("Last file access: %s", ctime(&st_atime));
printf("Last file modification: %s", ctime(&st_mtime));
#endif
exit(EXIT_SUCCESS);
}

Discussion


  • Anonymous
    2011-10-07

    mingw runtime patch

     
    Attachments
  • Earnie Boyd
    Earnie Boyd
    2012-11-12

    • labels: --> WSL (Windows System Libraries)
    • assigned_to: nobody --> earnie
     
  • Earnie Boyd
    Earnie Boyd
    2012-11-12

    I need to review the effects of this thoroughly.

     
  • Earnie Boyd
    Earnie Boyd
    2012-11-12

    • status: open --> open-postponed
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-04

    • labels: WSL (Windows System Libraries) -->
    • status: open-postponed --> pending
    • resolution: --> later
    • category: --> Known_bugs
    • milestone: --> WSL
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-08

    • type: --> Bug
    • patch_attached: --> False
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-19

    • type: Bug --> Task
    • category: Known_bugs --> Feature_in_WSL_4.1
    • patch_attached: False --> True