1 #include "syscall.h" 2 __procfdname(char * buf,unsigned fd)3void __procfdname(char *buf, unsigned fd) 4 { 5 unsigned i, j; 6 for (i=0; (buf[i] = "/proc/self/fd/"[i]); i++); 7 if (!fd) { 8 buf[i] = '0'; 9 buf[i+1] = 0; 10 return; 11 } 12 for (j=fd; j; j/=10, i++); 13 buf[i] = 0; 14 for (; fd; fd/=10) buf[--i] = '0' + fd%10; 15 } 16