[openMosix-it] file copy problem

ZIGLIO Frediano openmosix@democritos.it
Mon, 31 Mar 2003 15:55:04 +0200


I written this small C program to reproduce bug.
I hope it help...

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

#define FATAL \
{ perror("fatal: "); return 1; }

#define PROBLEM(s) \
{ fprintf(stderr,"%s\n",s); result = 1; }

int
main(int argc, char** argv)
{
        struct stat stat1, stat2;
        int fd;
        int result = 0;

        if (argc < 2) {
               fprintf(stderr, "stat <filename>\n");
               return 1;
        }

        if (stat(argv[1],&stat1))
               FATAL;

        fd = open(argv[1],O_RDONLY);
        if (fd < 0)
               FATAL;

        if (fstat(fd,&stat2))
               FATAL;

        if (stat1.st_mtime != stat2.st_mtime)
               PROBLEM("modified time changed???");

        if (stat1.st_ino != stat2.st_ino || stat1.st_dev != stat2.st_dev)
               PROBLEM("modified ino/dev");

        return result;
}

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================