k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit c0935a1b07fc6ebd68a19af9c15f035bc4a604fa
parent 0ee58ebd7b812a857740a7a11b423afcca501f69
Author: qorg11 <qorg@vxempire.xyz>
Date:   Tue, 28 Jul 2020 12:52:08 +0200

added errno to ln.c

Diffstat:
Msrc/ln.c | 50++++++++++++++++++++++++++------------------------
1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/ln.c b/src/ln.c @@ -1,10 +1,12 @@ #include <stdio.h> #include <unistd.h> +#include <errno.h> +#include <string.h> int main(int argc, char *argv[]) { - + if(argc == 1) { printf("Usage: ln oldfile newfile\n"); @@ -16,29 +18,29 @@ main(int argc, char *argv[]) if(opts == 'f') fflag=1; switch(opts) { - case 's': - if(fflag == 1 && (access(argv[3], F_OK) != 1)) { - if(remove(argv[3]) == -1) - rmdir(argv[3]); - } - int symstat = symlink(argv[2],argv[3]); - if(symstat == -1) - { - fprintf(stderr, "Symlink error!"); - return 1; - } - break; - case '?': - printf("-%c: Argument not found", optopt); - break; - default: - fd = link(argv[1],argv[2]); - if(fd == -1) - { - fprintf(stderr,"Error creating link\n"); - return 1; - } - return 0; + case 's': + if(fflag == 1 && (access(argv[3], F_OK) != 1)) { + if(remove(argv[3]) == -1) + rmdir(argv[3]); + } + int symstat = symlink(argv[2],argv[3]); + if(symstat == -1) + { + fprintf(stderr, "Symlink error!"); + return 1; + } + break; + case '?': + printf("-%c: Argument not found", optopt); + break; + default: + fd = link(argv[1],argv[2]); + if(fd == -1) + { + fprintf(stderr,"Error creating link: %i = %s\n",errno,strerror(errno)); + return 1; + } + return 0; } } }