c link() function failing to execute -


i have question regarding link() function in c. using create hard link file on unix system. first, in home direcotry (the same problem happens in other directories) create test directory , cd it. inside execute program creates hard link file in .. directory (the parent directory). reason failes errno set on 2 (enoent). file exists -> name ../exercise3.c (the name exercise3.c resides in .. directory) , reason creating links files ../scr.c , others works, cant create link file. has same privilages other text files in directory. have tryed debbuging deleting file , recreating (did not work), printing name of file in program see if code fail somehow, not. strange thing if stay in parent directory can create link file, go test directory created , try create link (the file in question) path name ../exercise3.c fails. again ../scr.c creates link.

int status = link(dest, name); if (status == 0) {     exitstatus = 0;  } else {     exitstatus = errno;     printf("failed: %s\n", dest);     perror("creating hard link: ");  } 

this function creates hard link. chardest ../exercise.c file , charname hard link name. , hard link name or dest dont point empty string.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -