#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>



int main(int argc, char ** argv){
    
    int fd, i;
    struct flock fl;
    char * name;
    
    name = argv[1];
    
    fl.l_whence = SEEK_SET;
    fl.l_start = 0;
    fl.l_len = 100;
    
    
    
    fd = open( name, O_RDWR );
    
    
    for (i=0; i<1000; i++){
        fl.l_type = F_WRLCK;
        fcntl(fd, F_SETLK, &fl);
        write(fd,"a", 1);
        fsync(fd);
        fl.l_type = F_UNLCK;
        fcntl(fd, F_SETLK, &fl);
    }
    close(fd);
    
    return 0;
    
}

