Skip to content

Instantly share code, notes, and snippets.

@hashar
Created July 31, 2012 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashar/3219650 to your computer and use it in GitHub Desktop.
Save hashar/3219650 to your computer and use it in GitHub Desktop.
move a file and crash gluster!
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
int main() {
puts( "Writing file 'ORIG_HEAD.lock'!" );
FILE *file;
file = fopen( "ORIG_HEAD.lock", "w+" );
fprintf( file, "some string\n" );
fclose( file );
puts( "Renaming file to 'ORIG_HEAD'" );
int rename_result=0;
rename_result = rename( "ORIG_HEAD.lock", "ORIG_HEAD" );
if( rename_result < 0 ) {
printf( "Error: %s\n", strerror( errno ) );
return -1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment