From d249fa1b2ce540b594b4098a6cdbc6acb14e014d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 5 Sep 2007 03:01:41 +0000 Subject: [PATCH] Map the fssh_*stat() functions to _kern_read_stat() in libroot_build on BeOS incompatible platforms. Thus *stat()ing symlinks works. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22178 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tools/fs_shell/stat.cpp | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/tools/fs_shell/stat.cpp b/src/tools/fs_shell/stat.cpp index 16ea10f669..dc5a59e9e6 100644 --- a/src/tools/fs_shell/stat.cpp +++ b/src/tools/fs_shell/stat.cpp @@ -7,8 +7,11 @@ #include "fssh_stat.h" +#include + #include +#include "fssh_errno.h" #include "stat_util.h" @@ -16,6 +19,13 @@ using FSShell::from_platform_stat; using FSShell::to_platform_mode; +#ifndef __BEOS__ + // The _kern_read_stat() defined in libroot_build.so. + extern "C" status_t _kern_read_stat(int fd, const char *path, + bool traverseLink, struct stat *st, size_t statSize); +#endif + + int fssh_mkdir(const char *path, fssh_mode_t mode) { @@ -27,8 +37,19 @@ int fssh_stat(const char *path, struct fssh_stat *fsshStat) { struct stat st; + + // Use the _kern_read_stat() defined in libroot on BeOS incompatible + // systems. Required for support for opening symlinks. +#if __BEOS__ if (stat(path, &st) < 0) return -1; +#else + status_t error = _kern_read_stat(-1, path, true, &st, sizeof(st)); + if (error < 0) { + fssh_set_errno(error); + return -1; + } +#endif from_platform_stat(&st, fsshStat); @@ -40,8 +61,19 @@ int fssh_fstat(int fd, struct fssh_stat *fsshStat) { struct stat st; + + // Use the _kern_read_stat() defined in libroot on BeOS incompatible + // systems. Required for support for opening symlinks. +#if __BEOS__ if (fstat(fd, &st) < 0) return -1; +#else + status_t error = _kern_read_stat(fd, NULL, false, &st, sizeof(st)); + if (error < 0) { + fssh_set_errno(error); + return -1; + } +#endif from_platform_stat(&st, fsshStat); @@ -53,8 +85,19 @@ int fssh_lstat(const char *path, struct fssh_stat *fsshStat) { struct stat st; + + // Use the _kern_read_stat() defined in libroot on BeOS incompatible + // systems. Required for support for opening symlinks. +#if __BEOS__ if (lstat(path, &st) < 0) return -1; +#else + status_t error = _kern_read_stat(-1, path, false, &st, sizeof(st)); + if (error < 0) { + fssh_set_errno(error); + return -1; + } +#endif from_platform_stat(&st, fsshStat);