Difference between hard mounting and soft mounting in NFS
Here is a small piece of code that I used to check out hard mounting and soft mounting NFS. Output at the end.
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#define NUM_SEC 60
int main(int argc, char **argv)
{
FILE *fp;
int i, sav_err;
if(argc < 2)
{
printf("Please enter file name. Usage %s \n", argv[1]);
return 1;
}
for(i = 0; i < NUM_SEC; i++)
{
fp = fopen(argv[1], "r");
sav_err = errno;
if(fp == NULL)
{
printf("\nAn error occured for file %s \n", argv[1]);
printf("\nError : %s\n", strerror(sav_err));
return 1;
}
else
{
printf("Successfully opened file : ");
system("date");
fclose(fp);
fflush(stdout);
}
sleep(1);
}
return 0;
}
Output :
-----------------Hard Mounting----------------- devendra@l:~/hda5/devendra$ sudo mount 10.1.30.2:/mnt/hda5 hda5 -o hard devendra@l:~$ cd hda5/devendra devendra@l:~/hda5/devendra$ ~/mit/ds/a.out music Mon Apr 24 23:16:48 EDT 2006 Successfully opened file : Mon Apr 24 23:16:49 EDT 2006 Successfully opened file : Mon Apr 24 23:16:50 EDT 2006 Successfully opened file : Mon Apr 24 23:16:51 EDT 2006 Successfully opened file : Mon Apr 24 23:16:52 EDT 2006 Successfully opened file : Mon Apr 24 23:16:53 EDT 2006 (Link goes down, program waits till link comes back again) Successfully opened file : Mon Apr 24 23:17:22 EDT 2006 (Link goes up) Successfully opened file : Mon Apr 24 23:17:23 EDT 2006 Successfully opened file : Mon Apr 24 23:17:24 EDT 2006 Successfully opened file : Mon Apr 24 23:17:25 EDT 2006 Successfully opened file : Mon Apr 24 23:17:26 EDT 2006 Successfully opened file : Mon Apr 24 23:17:27 EDT 2006 Successfully opened file : Mon Apr 24 23:17:28 EDT 2006 devendra@l:~/hda5/devendra$ cd .. devendra@l:~/hda5$ cd .. devendra@l:~$ sudo umount hda5 -----------------Soft Mounting----------------- devendra@l:~$ sudo mount 10.1.30.2:/mnt/hda5 hda5 -o soft devendra@l:~$ cd hda5/devendra/ devendra@l:~/hda5/devendra$ ~/mit/ds/a.out music Mon Apr 24 23:19:44 EDT 2006 Successfully opened file : Mon Apr 24 23:19:45 EDT 2006 Successfully opened file : Mon Apr 24 23:19:46 EDT 2006 Successfully opened file : Mon Apr 24 23:19:47 EDT 2006 Successfully opened file : Mon Apr 24 23:19:48 EDT 2006 Successfully opened file : Mon Apr 24 23:19:49 EDT 2006 Successfully opened file : Mon Apr 24 23:19:50 EDT 2006 Successfully opened file : Mon Apr 24 23:19:51 EDT 2006 Successfully opened file : Mon Apr 24 23:19:52 EDT 2006 Successfully opened file : (Link goes down, after few seconds, timeout occurs...) An error occured for file music Error : Input/output error devendra@l:~/hda5/devendra$

0 Comments:
Post a Comment
<< Home