nfs-ganesha 1.4

rename_hl.c

Go to the documentation of this file.
00001 #include<stdio.h>
00002 #include <stdlib.h>
00003 #include <unistd.h>
00004 #include <sys/param.h>
00005 #include <string.h>
00006 #include <errno.h>
00007 
00008 
00009 int main( int argc, char * argv[] )
00010 {
00011   int rc ;
00012   char file[MAXPATHLEN] ;
00013   char filehl[MAXPATHLEN] ;
00014   char cmd[MAXPATHLEN] ;
00015 
00016   if( argc != 2 )
00017     fprintf( stderr, "One argument is required to tell the path of the file to be used\n" ) ;
00018 
00019   strncpy( file, argv[1], MAXPATHLEN ) ;
00020   snprintf( filehl, MAXPATHLEN, "%s.hardlink", file ) ;
00021 
00022   rc = link( file, filehl ) ;
00023   printf( "link %s %s : rc=%d errno=(%u|%s)\n", file, filehl, rc, errno, strerror( errno ) ) ;
00024 
00025   rc = rename( file, filehl ) ;
00026   printf( "rename %s %s : rc=%d errno=(%u|%s)\n", file, filehl, rc, errno, strerror( errno ) ) ;
00027 
00028   snprintf( cmd, MAXPATHLEN, "ls -lid %s %s", file, filehl ) ;
00029   system( cmd ) ; 
00030 }