Skip to contentSkip to conversation

updated fstatat64 support

PATCH In review Ulrich Drepper 3 participants 5 messages Feb 10, 2006 – Feb 12, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 updated fstatat64 support

Since Christoph insist here's a patch changing newfstatat64 to fstatat64.

arch/i386/kernel/syscall_table.S renamed from arch/i386/kernel/syscall_table.S-at +1 -1
@@ -299,7 +299,7 @@
 	.long sys_mknodat
 	.long sys_fchownat
 	.long sys_futimesat
-	.long sys_newfstatat		/* 300 */
+	.long sys_fstatat64		/* 300 */
 	.long sys_unlinkat
 	.long sys_renameat
 	.long sys_linkat
arch/x86_64/ia32/ia32entry.S renamed from arch/x86_64/ia32/ia32entry.S-at +1 -1
@@ -677,7 +677,7 @@
 	.quad sys_mknodat
 	.quad sys_fchownat
 	.quad compat_sys_futimesat
-	.quad compat_sys_newfstatat	/* 300 */
+	.quad sys32_fstatat		/* 300 */
 	.quad sys_unlinkat
 	.quad sys_renameat
 	.quad sys_linkat
arch/x86_64/ia32/sys_ia32.c renamed from arch/x86_64/ia32/sys_ia32.c-at +22 -0
@@ -180,6 +180,28 @@
 	return ret;
 }
 
+asmlinkage long
+sys32_fstatat(unsigned int dfd, char __user *filename,
+	      struct stat64 __user* statbuf, int flag)
+{
+	struct kstat stat;
+	int error = -EINVAL;
+
+	if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
+		goto out;
+
+	if (flag & AT_SYMLINK_NOFOLLOW)
+		error = vfs_lstat_fd(dfd, filename, &stat);
+	else
+		error = vfs_stat_fd(dfd, filename, &stat);
+
+	if (!error)
+		error = cp_stat64(statbuf, &stat);
+
+out:
+	return error;
+}
+
 /*
  * Linux/i386 didn't use to be able to handle more than
  * 4 system call parameters, so these system calls used a memory
fs/stat.c renamed from fs/stat.c-at +22 -0
@@ -261,6 +261,7 @@
 	return error;
 }
 
+#ifndef __ARCH_WANT_STAT64
 asmlinkage long sys_newfstatat(int dfd, char __user *filename,
 				struct stat __user *statbuf, int flag)
 {
@@ -281,6 +282,7 @@
 out:
 	return error;
 }
+#endif
 
 asmlinkage long sys_newfstat(unsigned int fd, struct stat __user *statbuf)
 {
@@ -395,6 +397,26 @@
 	return error;
 }
 
+asmlinkage long sys_fstatat64(int dfd, char __user *filename,
+			       struct stat64 __user *statbuf, int flag)
+{
+	struct kstat stat;
+	int error = -EINVAL;
+
+	if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
+		goto out;
+
+	if (flag & AT_SYMLINK_NOFOLLOW)
+		error = vfs_lstat_fd(dfd, filename, &stat);
+	else
+		error = vfs_stat_fd(dfd, filename, &stat);
+
+	if (!error)
+		error = cp_new_stat64(&stat, statbuf);
+
+out:
+	return error;
+}
 #endif /* __ARCH_WANT_STAT64 */
 
 void inode_add_bytes(struct inode *inode, loff_t bytes)
include/asm-i386/unistd.h renamed from include/asm-i386/unistd.h-at +1 -1
@@ -305,7 +305,7 @@
 #define __NR_mknodat		297
 #define __NR_fchownat		298
 #define __NR_futimesat		299
-#define __NR_newfstatat		300
+#define __NR_fstatat64		300
 #define __NR_unlinkat		301
 #define __NR_renameat		302
 #define __NR_linkat		303
include/asm-x86_64/ia32_unistd.h renamed from include/asm-x86_64/ia32_unistd.h-at +1 -1
@@ -305,7 +305,7 @@
 #define __NR_ia32_mknodat		297
 #define __NR_ia32_fchownat		298
 #define __NR_ia32_futimesat		299
-#define __NR_ia32_newfstatat		300
+#define __NR_ia32_fstatat64		300
 #define __NR_ia32_unlinkat		301
 #define __NR_ia32_renameat		302
 #define __NR_ia32_linkat		303
include/linux/syscalls.h renamed from include/linux/syscalls.h-at +2 -0
@@ -557,6 +557,8 @@
 			   int mode);
 asmlinkage long sys_newfstatat(int dfd, char __user *filename,
 			       struct stat __user *statbuf, int flag);
+asmlinkage long sys_fstatat64(int dfd, char __user *filename,
+			       struct stat64 __user *statbuf, int flag);
 asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf,
 			       int bufsiz);
 asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename,
#1 lore raw
Quoted 14 lines
arch/i386/kernel/syscall_table.S renamed from arch/i386/kernel/syscall_table.S-at +1 -1
@@ -299,7 +299,7 @@
 	.long sys_mknodat
 	.long sys_fchownat
 	.long sys_futimesat
-	.long sys_newfstatat		/* 300 */
+	.long sys_fstatat64		/* 300 */
 	.long sys_unlinkat
 	.long sys_renameat
 	.long sys_linkat

arch/x86_64/ia32/ia32entry.S line 683

Quoted 8 lines
arch/x86_64/ia32/ia32entry.S renamed from arch/x86_64/ia32/ia32entry.S-at +1 -1
@@ -677,7 +677,7 @@
 	.quad sys_mknodat
 	.quad sys_fchownat
 	.quad compat_sys_futimesat
-	.quad compat_sys_newfstatat	/* 300 */
+	.quad sys32_fstatat		/* 300 */
 	.quad sys_unlinkat
 	.quad sys_renameat
 	.quad sys_linkat

So we end up with sys_newfstatat for 64 bit architectures, sys_fstatat64 for 32 bit architectures and sys32_fstatat for compat mode. Shouldn't the name of the compat call changed to sys32_fstatat64?
At least that is how it used to be for all other *64 compat system calls like e.g. fstat64.

Heiko

#2 lore raw

s390 doesnt compile because sys_newfstatat() is not defined. __ARCH_WANT_STAT64 is defined for 32bit build in include/asm-s390/unistd.h. This change fixes compilation, but its likely not correct to do it that way:

fs/stat.c +1 -1
Index: linux-2.6.15/fs/stat.c
===================================================================
@@ -261,7 +261,7 @@ asmlinkage long sys_newlstat(char __user
        return error;
 }
 
-#ifndef __ARCH_WANT_STAT64
+#ifdef __ARCH_WANT_STAT64
 asmlinkage long sys_newfstatat(int dfd, char __user *filename,
                                struct stat __user *statbuf, int flag)
 {
Signature · 2 lines
short story of a lazy sysadmin:
 alias appserv=wotan
#3 lore raw
Quoted 4 lines · Olaf Hering

s390 doesnt compile because sys_newfstatat() is not defined. __ARCH_WANT_STAT64 is defined for 32bit build in include/asm-s390/unistd.h. This change fixes compilation, but its likely not correct to do it that way:

Indeed. You most probably want to change the reference in the syscall table to sys_fstatat64.

Signature · 1 line
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
#4 lore raw
Quoted 6 lines
Quoted 4 lines

s390 doesnt compile because sys_newfstatat() is not defined. __ARCH_WANT_STAT64 is defined for 32bit build in include/asm-s390/unistd.h. This change fixes compilation, but its likely not correct to do it that way:

Indeed. You most probably want to change the reference in the syscall table to sys_fstatat64.

I sent a patch which fixes this earlier today:

http://lkml.org/lkml/2006/2/12/37

Thanks,
Heiko