Re: very weired random io behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



sorry. my dumb.

here is not 
x = (rand() >> 1) << 1;
but
x = (rand() >> 10) << 10;

file is in bytes while lba is in sector. ;P

ming



On Fri, 2005-08-26 at 16:08 -0400, Ming Zhang wrote:

> ---------------------------------------------------
> #define _LARGEFILE64_SOURCE
> 
> #include <stdlib.h>
> #include <sys/types.h>
> #include <unistd.h>
> #include <fcntl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> 
> int main(int argc, char *argv[])
> {
>         int n;
>         int i, count;
>         char *name;
>         char buf[4096];
>         int fd;
> 
>         if (argc != 3) {
>                 printf("%s name count\n", argv[0]);
>                 exit(1);
>         }
>         name = argv[1];
>         count = atoi(argv[2]);
> 
>         fd = open(name, O_CREAT|O_WRONLY, S_IRWXU);
>         for (i = 0; i < count; i++) {
>                 unsigned long x;
> 
>                 x = (rand() >> 1) << 1;
>                 lseek64(fd, x, SEEK_SET);
>                 write(fd, buf, 4096);
>         }
>         printf("done\n");
>         close(fd);
>         return 0;
> }
> 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux