用下面的代码,编译生成一个, 后放到bin中。运行如下命令即可以
cc realpath.c -o realpath.
sudo chown root:root realpath
sudo chmod 755 realpath
sudo cp realpath /bin
If you put it into other directories, you may need to follow up with chmod +s realpath
CODE FOLLOWS.
/********************** temporary version of realpath ***********************
* use until a coreutils version is produced. This version does the minimum *
* necessary to resolve relative to absolute paths. One argument, the input string to be resolved.
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(int argc,char **argv)
{
char rlpath[PATH_MAX];
char *cp;
if (argc==2)
{
cp= realpath(argv[1],rlpath);
fprintf(stdout,"%s\n",cp);
exit(0);
}
exit(1);
}