diff --git a/scsh/syscalls1.c b/scsh/syscalls1.c index 3d9c872..19c0cb1 100644 --- a/scsh/syscalls1.c +++ b/scsh/syscalls1.c @@ -189,7 +189,7 @@ s48_value scsh_kill (s48_value sch_pid, s48_value sch_signal) /* Read the symlink. */ - +#ifdef MAXPATHLEN s48_value scsh_readlink(s48_value sch_path) { char linkpath[MAXPATHLEN+1]; @@ -202,6 +202,37 @@ s48_value scsh_readlink(s48_value sch_path) return s48_enter_string(linkpath); } } +#else +s48_value scsh_readlink(s48_value sch_path) +{ + char *linkpath; + int size; + int retval; + s48_value sch_sym_link_path = S48_UNSPECIFIC; + + for (size = 256;; size *=2){ + + linkpath = Malloc(char,size); + if (!linkpath) + s48_raise_os_error_1(errno, sch_path); + + retval = readlink(s48_extract_string (sch_path), linkpath, size); + + if (retval == -1){ + free (linkpath); + s48_raise_os_error_1(errno, sch_path); + } + + if (retval < size){ + sch_sym_link_path = s48_enter_substring (linkpath, retval); + free (linkpath); + return sch_sym_link_path; + } + free (linkpath); + } +} +#endif + s48_value scsh_rename(s48_value sch_from, s48_value sch_to) {