Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/system_calls.html on line 13

Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/system_calls.html on line 13

Warning: include(): Failed opening 'topsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/system_calls.html on line 13

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 


Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/system_calls.html on line 31

Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/system_calls.html on line 31

Warning: include(): Failed opening 'adsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/system_calls.html on line 31

 
implementation of LN command using system calls

--------------------------------------------------------------------------------

Description : this program implement the ln command in unix using system calls.

#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/stat.h>
int main(int argc,char* argv[])
{
int i;
struct stat s;
if (argc<3)
{
perror("ERROR:Too Few Arguments");
exit(1);
}
if(argc>4)
{
perror("ERROR:Too Many Arguments");
exit(1);
}
if(argc==3)
i=0;
else
i=1;

if(i && !(strcmp(argv[1],"-s")==0)) {
perror("ERROR:Invalid Syntax");
exit(1);
}

if(access(argv[i+1],F_OK))
{
perror("ERROR:File name not Found");
exit(1);
}
if(!access(argv[i+2],F_OK))
{
perror("ERROR:File Name already exist");
exit(1);
}
if(stat(argv[i+1],&s)<0)
{
perror("ERROR:Unable to reterive stat information");
exit(1);
}
if(!S_ISREG(s.st_mode))
{
perror("ERROR:Not a Regular File");
exit(1); }
if(argc==3)
if(link(argv[i+1],argv[i+2])<0)
{
perror("ERROR:Unable to create the Link");
exit(1);
}
if(argc==4)
if(symlink(argv[i+1],argv[i+2])<0)
{
perror("ERROR:Unable to create the Link");
exit(1);
}
}

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG