Skip to contentSkip to conversation

linux/ufs_fs.h: use __u64 for userspace

PATCH In review Mike Frysinger 4 participants 6 messages Jan 2, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/ufs_fs.h: use __u64 for userspace

Fix the ufs_inotofsba macro to use __u64 rather than u64 since this is exported to userspace.

---

include/linux/ufs_fs.h +1 -1
index 10b854d..35b6e59 100644
@@ -225,7 +225,7 @@ typedef __u16 __bitwise __fs16;
  */
 #define	ufs_inotocg(x)		((x) / uspi->s_ipg)
 #define	ufs_inotocgoff(x)	((x) % uspi->s_ipg)
-#define	ufs_inotofsba(x)	(((u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf)
+#define	ufs_inotofsba(x)	(((__u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf)
 #define	ufs_inotofsbo(x)	((x) % uspi->s_inopf)
 
 /*
#1 lore raw
Quoted 10 lines · Mike Frysinger

Fix the ufs_inotofsba macro to use __u64 rather than u64 since this is exported to userspace.

---

include/linux/ufs_fs.h +0 -0
index 10b854d..35b6e59 100644

include/linux/ufs_fs.h typedef __u16 __bitwise __fs16; · line 229

Quoted 6 lines
include/linux/ufs_fs.h +1 -1
@@ -225,7 +225,7 @@ typedef __u16 __bitwise __fs16;
  */
 #define	ufs_inotocg(x)		((x) / uspi->s_ipg)
 #define	ufs_inotocgoff(x)	((x) % uspi->s_ipg)
-#define	ufs_inotofsba(x)	(((u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf)
+#define	ufs_inotofsba(x)	(((__u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf)
 #define	ufs_inotofsbo(x)	((x) % uspi->s_inopf)

But userspace anyway can't use them since it doesn't know what "uspi" is, so you should better reduce the userspace visibility of this header.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#2 lore raw
Quoted 2 lines · Adrian Bunk

But userspace anyway can't use them since it doesn't know what "uspi" is, so you should better reduce the userspace visibility of this header.

We had this come up before and the header should not be exported to userspace at all. It documents the ufs ondisk structures which are

a) not a user/kernel interface
b) may change frequently due to addition of another ufs subvariant.

The only non-kernel user of this known to me is silo, which should just have it's own header documenting the solaris sparc ufs variant it needs to understand, possibly by using a copy of the kernel version at any given point of time.

#3 lore raw

From: Christoph Hellwig <[email protected]>
Date: Wed, 2 Jan 2008 07:50:33 +0000

Quoted 4 lines

The only non-kernel user of this known to me is silo, which should just have it's own header documenting the solaris sparc ufs variant it needs to understand, possibly by using a copy of the kernel version at any given point of time.

And this is what the current SILO sources do.

#4 lore raw
Quoted 9 lines · David Miller

From: Christoph Hellwig <[email protected]>
Date: Wed, 2 Jan 2008 07:50:33 +0000

Quoted 4 lines

The only non-kernel user of this known to me is silo, which should just have it's own header documenting the solaris sparc ufs variant it needs to understand, possibly by using a copy of the kernel version at any given point of time.

And this is what the current SILO sources do.

Nice.

#5 lore raw

Re: [patch] linux/ufs_fs.h: do not export to userspace anymore

In reply to David Miller
Quoted 7 lines · David Miller

From: Christoph Hellwig <[email protected]>

Quoted 4 lines

The only non-kernel user of this known to me is silo, which should just have it's own header documenting the solaris sparc ufs variant it needs to understand, possibly by using a copy of the kernel version at any given point of time.

And this is what the current SILO sources do.

then if silo has gotten its stuff together ...
---
Do not export linux/ufs_fs.h to userspace anymore as the only userspace consumer has been fixed to not need it anymore.

---

include/linux/Kbuild +0 -1
index f30fa92..fd2570f 100644
@@ -336,7 +336,6 @@ unifdef-y += tty.h
 unifdef-y += types.h
 unifdef-y += udf_fs_i.h
 unifdef-y += udp.h
-unifdef-y += ufs_fs.h
 unifdef-y += uinput.h
 unifdef-y += uio.h
 unifdef-y += unistd.h
include/linux/ufs_fs.h +0 -6
index 10b854d..46e4a8d 100644
@@ -35,16 +35,10 @@
 #include <linux/stat.h>
 #include <linux/fs.h>
 
-#ifndef __KERNEL__
-typedef __u64 __fs64;
-typedef __u32 __fs32;
-typedef __u16 __fs16;
-#else
 #include <asm/div64.h>
 typedef __u64 __bitwise __fs64;
 typedef __u32 __bitwise __fs32;
 typedef __u16 __bitwise __fs16;
-#endif
 
 #define UFS_BBLOCK 0
 #define UFS_BBSIZE 8192