aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/gfs2/ops_file.c74
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/iflags.h102
4 files changed, 49 insertions, 130 deletions
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index fafa48b9105e..3064f133bf3c 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -21,7 +21,6 @@
21#include <linux/gfs2_ondisk.h> 21#include <linux/gfs2_ondisk.h>
22#include <linux/ext2_fs.h> 22#include <linux/ext2_fs.h>
23#include <linux/crc32.h> 23#include <linux/crc32.h>
24#include <linux/iflags.h>
25#include <linux/lm_interface.h> 24#include <linux/lm_interface.h>
26#include <asm/uaccess.h> 25#include <asm/uaccess.h>
27 26
@@ -201,27 +200,48 @@ static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir)
201 return error; 200 return error;
202} 201}
203 202
203/**
204 * fsflags_cvt
205 * @table: A table of 32 u32 flags
206 * @val: a 32 bit value to convert
207 *
208 * This function can be used to convert between fsflags values and
209 * GFS2's own flags values.
210 *
211 * Returns: the converted flags
212 */
213static u32 fsflags_cvt(const u32 *table, u32 val)
214{
215 u32 res = 0;
216 while(val) {
217 if (val & 1)
218 res |= *table;
219 table++;
220 val >>= 1;
221 }
222 return res;
223}
204 224
205static const u32 iflags_to_gfs2[32] = { 225static const u32 fsflags_to_gfs2[32] = {
206 [iflag_Sync] = GFS2_DIF_SYNC, 226 [3] = GFS2_DIF_SYNC,
207 [iflag_Immutable] = GFS2_DIF_IMMUTABLE, 227 [4] = GFS2_DIF_IMMUTABLE,
208 [iflag_Append] = GFS2_DIF_APPENDONLY, 228 [5] = GFS2_DIF_APPENDONLY,
209 [iflag_NoAtime] = GFS2_DIF_NOATIME, 229 [7] = GFS2_DIF_NOATIME,
210 [iflag_Index] = GFS2_DIF_EXHASH, 230 [12] = GFS2_DIF_EXHASH,
211 [iflag_JournalData] = GFS2_DIF_JDATA, 231 [14] = GFS2_DIF_JDATA,
212 [iflag_DirectIO] = GFS2_DIF_DIRECTIO, 232 [20] = GFS2_DIF_DIRECTIO,
213}; 233};
214 234
215static const u32 gfs2_to_iflags[32] = { 235static const u32 gfs2_to_fsflags[32] = {
216 [gfs2fl_Sync] = IFLAG_SYNC, 236 [gfs2fl_Sync] = FS_SYNC_FL,
217 [gfs2fl_Immutable] = IFLAG_IMMUTABLE, 237 [gfs2fl_Immutable] = FS_IMMUTABLE_FL,
218 [gfs2fl_AppendOnly] = IFLAG_APPEND, 238 [gfs2fl_AppendOnly] = FS_APPEND_FL,
219 [gfs2fl_NoAtime] = IFLAG_NOATIME, 239 [gfs2fl_NoAtime] = FS_NOATIME_FL,
220 [gfs2fl_ExHash] = IFLAG_INDEX, 240 [gfs2fl_ExHash] = FS_INDEX_FL,
221 [gfs2fl_Jdata] = IFLAG_JOURNAL_DATA, 241 [gfs2fl_Jdata] = FS_JOURNAL_DATA_FL,
222 [gfs2fl_Directio] = IFLAG_DIRECTIO, 242 [gfs2fl_Directio] = FS_DIRECTIO_FL,
223 [gfs2fl_InheritDirectio] = IFLAG_DIRECTIO, 243 [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL,
224 [gfs2fl_InheritJdata] = IFLAG_JOURNAL_DATA, 244 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
225}; 245};
226 246
227static int gfs2_get_flags(struct file *filp, u32 __user *ptr) 247static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
@@ -230,15 +250,15 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
230 struct gfs2_inode *ip = GFS2_I(inode); 250 struct gfs2_inode *ip = GFS2_I(inode);
231 struct gfs2_holder gh; 251 struct gfs2_holder gh;
232 int error; 252 int error;
233 u32 iflags; 253 u32 fsflags;
234 254
235 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); 255 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
236 error = gfs2_glock_nq_m_atime(1, &gh); 256 error = gfs2_glock_nq_m_atime(1, &gh);
237 if (error) 257 if (error)
238 return error; 258 return error;
239 259
240 iflags = iflags_cvt(gfs2_to_iflags, ip->i_di.di_flags); 260 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags);
241 if (put_user(iflags, ptr)) 261 if (put_user(fsflags, ptr))
242 error = -EFAULT; 262 error = -EFAULT;
243 263
244 gfs2_glock_dq_m(1, &gh); 264 gfs2_glock_dq_m(1, &gh);
@@ -327,19 +347,19 @@ out:
327 347
328static int gfs2_set_flags(struct file *filp, u32 __user *ptr) 348static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
329{ 349{
330 u32 iflags, gfsflags; 350 u32 fsflags, gfsflags;
331 if (get_user(iflags, ptr)) 351 if (get_user(fsflags, ptr))
332 return -EFAULT; 352 return -EFAULT;
333 gfsflags = iflags_cvt(iflags_to_gfs2, iflags); 353 gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags);
334 return do_gfs2_set_flags(filp, gfsflags, ~0); 354 return do_gfs2_set_flags(filp, gfsflags, ~0);
335} 355}
336 356
337static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 357static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
338{ 358{
339 switch(cmd) { 359 switch(cmd) {
340 case IFLAGS_GET_IOC: 360 case FS_IOC_GETFLAGS:
341 return gfs2_get_flags(filp, (u32 __user *)arg); 361 return gfs2_get_flags(filp, (u32 __user *)arg);
342 case IFLAGS_SET_IOC: 362 case FS_IOC_SETFLAGS:
343 return gfs2_set_flags(filp, (u32 __user *)arg); 363 return gfs2_set_flags(filp, (u32 __user *)arg);
344 } 364 }
345 return -ENOTTY; 365 return -ENOTTY;
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 839a97ee1f7c..15667cc947d5 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -223,7 +223,6 @@ unifdef-y += hpet.h
223unifdef-y += i2c.h 223unifdef-y += i2c.h
224unifdef-y += i2o-dev.h 224unifdef-y += i2o-dev.h
225unifdef-y += icmpv6.h 225unifdef-y += icmpv6.h
226unifdef-y += iflags.h
227unifdef-y += if_bridge.h 226unifdef-y += if_bridge.h
228unifdef-y += if_ec.h 227unifdef-y += if_ec.h
229unifdef-y += if_eql.h 228unifdef-y += if_eql.h
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2e29a2edaeec..bc0e645abb80 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -250,6 +250,8 @@ extern int dir_notify_enable;
250#define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */ 250#define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
251#define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */ 251#define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
252#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ 252#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
253#define FS_EXTENT_FL 0x00080000 /* Extents */
254#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
253#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ 255#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
254 256
255#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ 257#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
diff --git a/include/linux/iflags.h b/include/linux/iflags.h
deleted file mode 100644
index 5b27102dfeaf..000000000000
--- a/include/linux/iflags.h
+++ /dev/null
@@ -1,102 +0,0 @@
1#ifndef _LINUX_IFLAGS_H
2#define _LINUX_IFLAGS_H
3
4/*
5 * A universal set of inode flags.
6 *
7 * Originally taken from ext2/3 with additions for other filesystems.
8 * Filesystems supporting this interface should interoperate with
9 * the lsattr and chattr command line tools.
10 *
11 * This interface is supported in whole or in part by:
12 * ext2
13 * ext3
14 * xfs
15 * jfs
16 * gfs2
17 *
18 */
19
20#define IFLAGS_GET_IOC _IOR('f', 1, long)
21#define IFLAGS_SET_IOC _IOW('f', 2, long)
22
23/*
24 * These values are provided for use as indices of an array
25 * for use with the iflags_cvt function below
26 */
27enum {
28 iflag_SecureRm = 0, /* Secure deletion */
29 iflag_Unrm = 1, /* Undelete */
30 iflag_Compress = 2, /* Compress file */
31 iflag_Sync = 3, /* Synchronous updates */
32 iflag_Immutable = 4, /* Immutable */
33 iflag_Append = 5, /* Append */
34 iflag_NoDump = 6, /* Don't dump file */
35 iflag_NoAtime = 7, /* No atime updates */
36 /* Reserved for compression usage */
37 iflag_Dirty = 8,
38 iflag_ComprBlk = 9, /* One or more compressed clusters */
39 iflag_NoComp = 10, /* Don't compress */
40 iflag_Ecompr = 11, /* Compression error */
41 /* End of compression flags */
42 iflag_Btree = 12, /* btree format dir */
43 iflag_Index = 12, /* hash-indexed directory */
44 iflag_Imagic = 13, /* AFS directory */
45 iflag_JournalData = 14, /* file data should be journaled */
46 iflag_NoTail = 15, /* file tail should not be merged */
47 iflag_DirSync = 16, /* dirsync behaviour */
48 iflag_TopDir = 17, /* Top of directory hierarchies */
49 iflag_Extent = 19, /* Extents */
50 iflag_DirectIO = 20, /* Always use direct I/O on this file */
51 iflag_Reserved = 31 /* reserved for ext2/3 lib */
52};
53
54#define __IFL(x) (1<<(iflag_##x))
55#define IFLAG_SECRM __IFL(SecureRm) /* 0x00000001 */
56#define IFLAG_UNRM __IFL(Unrm) /* 0x00000002 */
57#define IFLAG_COMPR __IFL(Compr) /* 0x00000004 */
58#define IFLAG_SYNC __IFL(Sync) /* 0x00000008 */
59#define IFLAG_IMMUTABLE __IFL(Immutable) /* 0x00000010 */
60#define IFLAG_APPEND __IFL(Append) /* 0x00000020 */
61#define IFLAG_NODUMP __IFL(NoDump) /* 0x00000040 */
62#define IFLAG_NOATIME __IFL(NoAtime) /* 0x00000080 */
63#define IFLAG_DIRTY __IFL(Dirty) /* 0x00000100 */
64#define IFLAG_COMPRBLK __IFL(ComprBlk) /* 0x00000200 */
65#define IFLAG_NOCOMP __IFL(NoComp) /* 0x00000400 */
66#define IFLAG_ECOMPR __IFL(Ecompr) /* 0x00000800 */
67#define IFLAG_BTREE __IFL(Btree) /* 0x00001000 */
68#define IFLAG_INDEX __IFL(Index) /* 0x00001000 */
69#define IFLAG_IMAGIC __IFL(Imagic) /* 0x00002000 */
70#define IFLAG_JOURNAL_DATA __IFL(JournalData) /* 0x00004000 */
71#define IFLAG_NOTAIL __IFL(NoTail) /* 0x00008000 */
72#define IFLAG_DIRSYNC __IFL(DirSync) /* 0x00010000 */
73#define IFLAG_TOPDIR __IFL(TopDir) /* 0x00020000 */
74#define IFLAG_EXTENT __IFL(Extent) /* 0x00080000 */
75#define IFLAG_DIRECTIO __IFL(DirectIO) /* 0x00100000 */
76#define IFLAG_RESERVED __IFL(Reserved) /* 0x80000000 */
77
78#ifdef __KERNEL__
79/**
80 * iflags_cvt
81 * @table: A table of 32 u32 flags
82 * @val: a 32 bit value to convert
83 *
84 * This function can be used to convert between IFLAGS values and
85 * the filesystem's own flags values.
86 *
87 * Returns: the converted flags
88 */
89static inline u32 iflags_cvt(const u32 *table, u32 val)
90{
91 u32 res = 0;
92 while(val) {
93 if (val & 1)
94 res |= *table;
95 table++;
96 val >>= 1;
97 }
98 return res;
99}
100#endif /* __KERNEL__ */
101
102#endif /* _LINUX_IFLAGS_H */