#include <sys/stat.h>
#include "xstatconv.h"
-#define __NR___syscall_fstat __NR_fstat
-static __inline__ _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf)
-
int fstat(int fd, struct stat *buf)
{
int result;
+#ifdef __NR_fstat64
+ /* normal stat call has limited values for various stat elements
+ * e.g. uid device major/minor etc.
+ * so we use 64 variant if available
+ * in order to get newer versions of stat elements
+ */
+ struct kernel_stat64 kbuf;
+ result = INLINE_SYSCALL(fstat64, 2, fd, &kbuf);
+ if (result == 0) {
+ __xstat32_conv(&kbuf, buf);
+ }
+#else
struct kernel_stat kbuf;
- result = __syscall_fstat(fd, &kbuf);
+ result = INLINE_SYSCALL(fstat, 2, fd, &kbuf);
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
+#endif
return result;
}
libc_hidden_def(fstat)
#include <sys/stat.h>
#include "xstatconv.h"
-#define __NR___syscall_lstat __NR_lstat
-static __inline__ _syscall2(int, __syscall_lstat,
- const char *, file_name, struct kernel_stat *, buf)
-
int lstat(const char *file_name, struct stat *buf)
{
int result;
+#ifdef __NR_lstat64
+ /* normal stat call has limited values for various stat elements
+ * e.g. uid device major/minor etc.
+ * so we use 64 variant if available
+ * in order to get newer versions of stat elements
+ */
+ struct kernel_stat64 kbuf;
+ result = INLINE_SYSCALL(lstat64, 2, file_name, &kbuf);
+ if (result == 0) {
+ __xstat32_conv(&kbuf, buf);
+ }
+#else
struct kernel_stat kbuf;
- result = __syscall_lstat(file_name, &kbuf);
+ result = INLINE_SYSCALL(lstat, 2, file_name, &kbuf);
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
+#endif
return result;
}
libc_hidden_def(lstat)
#include <sys/stat.h>
#include "xstatconv.h"
-#define __NR___syscall_stat __NR_stat
#undef stat
-static __inline__ _syscall2(int, __syscall_stat,
- const char *, file_name, struct kernel_stat *, buf)
int stat(const char *file_name, struct stat *buf)
{
int result;
+#ifdef __NR_stat64
+ /* normal stat call has limited values for various stat elements
+ * e.g. uid device major/minor etc.
+ * so we use 64 variant if available
+ * in order to get newer versions of stat elements
+ */
+ struct kernel_stat64 kbuf;
+ result = INLINE_SYSCALL(stat64, 2, file_name, &kbuf);
+ if (result == 0) {
+ __xstat32_conv(&kbuf, buf);
+ }
+#else
struct kernel_stat kbuf;
- result = __syscall_stat(file_name, &kbuf);
+ result = INLINE_SYSCALL(stat, 2, file_name, &kbuf);
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
+#endif
return result;
}
libc_hidden_def(stat)
--- /dev/null
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+int main()
+{
+ struct stat statbuf;
+ int ret = 0;
+ char* loop255 = "/dev/loop255";
+ char* loop256 = "/dev/loop256";
+ mode_t mode = 0660;
+ mknod(loop255, mode, 0x7ff);
+ mknod(loop256, mode, 0x100700);
+ ret = stat(loop255, &statbuf);
+ if(ret < 0) {
+ printf("stat: Cant stat %s\n",loop255);
+ unlink(loop255);
+ exit(1);
+ }
+ ret = stat(loop256, &statbuf);
+ if(ret < 0) {
+ printf("stat: Cant stat %s\n",loop256);
+ unlink(loop255);
+ unlink(loop256);
+ exit(1);
+ }
+
+ unlink(loop255);
+ unlink(loop256);
+ exit(0);
+}
+