Author: andreas
Date: Sun Jan 2 16:34:27 2005
New Revision: 9725
Modified:
trunk/src/common/system/file-system/unix-file-system.dylan
Log:
bug: 7226
Cope with the fact that on some systems, there are no arbitrary limits
for path size, and allocate a fixed-size buffer for readlink. The buffer
is grown in case 1024 bytes are insufficient.
Modified: trunk/src/common/system/file-system/unix-file-system.dylan
==============================================================================
--- trunk/src/common/system/file-system/unix-file-system.dylan (original)
+++ trunk/src/common/system/file-system/unix-file-system.dylan Sun Jan 2
16:34:27 2005
@@ -112,16 +112,23 @@
while (%file-type(link, if-not-exists: #"file") == #"link")
let link-path = as(<byte-string>, link);
let buffer-size = %pathconf(link-path, $_PC_SYMLINK_MAX);
- let buffer = make(<c-string>, size: buffer-size, fill: '\0');
- let count = %readlink(link-path, buffer, buffer-size);
- if (count = -1)
- unless (unix-last-error() = $ENOENT | unix-last-error() = $EINVAL)
- unix-file-error("readlink", "%s", link)
- end
- else
- let target = as(<file-system-locator>, copy-sequence(buffer, end:
count));
- link := merge-locators(target, link)
- end
+ local method try-with-buffer-size(buffer-size :: <integer>)
+ let buffer = make(<c-string>, size: buffer-size + 1, fill: '\0');
+ let count = %readlink(link-path, buffer, buffer-size);
+ if (count = buffer-size)
+ try-with-buffer-size(2 * buffer-size)
+ else
+ if (count = -1)
+ unless (unix-last-error() = $ENOENT | unix-last-error() =
$EINVAL)
+ unix-file-error("readlink", "%s", link)
+ end
+ else
+ let target = as(<file-system-locator>, copy-sequence(buffer,
end: count));
+ link := merge-locators(target, link)
+ end
+ end if;
+ end method try-with-buffer-size;
+ try-with-buffer-size(if (buffer-size > 0) buffer-size else 1024 end);
end;
link
end function %link-target;
_______________________________________________
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter
|