* Aligned the semantics of the read_symlink() FS module hook with the

readlink() function. It is no longer required to null-terminate the
  string, shall not fail, if the buffer is too small, and shall return
  the length of the string actually written into the buffer.
* Adjusted rootfs, devfs, and bfs accordingly. Also adjusted their
  read_stat() hooks to return the correct symlink length in st_size.
* Our readlink() does now comply to the standard (and BeOS).
  Additionally if the buffer is big enough it is nice to non-conforming
  apps and null-terminates it.
* BSymLink::ReadLink() explicitly null-terminates the string now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24425 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-03-17 21:37:40 +00:00
parent 4f893e39ab
commit 1b32947d3f
9 changed files with 61 additions and 45 deletions
+5 -6
View File
@@ -1880,13 +1880,10 @@ devfs_read_link(fs_volume _fs, fs_vnode _link, char *buffer, size_t *_bufferSize
if (!S_ISLNK(link->stream.type))
return B_BAD_VALUE;
*_bufferSize = link->stream.u.symlink.length + 1;
// we always need to return the number of bytes we intend to write!
if (link->stream.u.symlink.length < *_bufferSize)
*_bufferSize = link->stream.u.symlink.length;
if (bufferSize <= link->stream.u.symlink.length)
return B_BUFFER_OVERFLOW;
memcpy(buffer, link->stream.u.symlink.path, link->stream.u.symlink.length + 1);
memcpy(buffer, link->stream.u.symlink.path, *_bufferSize);
return B_OK;
}
@@ -2478,6 +2475,8 @@ devfs_read_stat(fs_volume _fs, fs_vnode _vnode, struct stat *stat)
// is this a real block device? then let's have it reported like that
if (stat->st_size != 0)
stat->st_mode = S_IFBLK | (vnode->stream.type & S_IUMSK);
} else if (S_ISLNK(vnode->stream.type)) {
stat->st_size = vnode->stream.u.symlink.length;
}
return B_OK;