Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2004-2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_IOCTL32_H__
0007 #define __XFS_IOCTL32_H__
0008 
0009 #include <linux/compat.h>
0010 
0011 /*
0012  * on 32-bit arches, ioctl argument structures may have different sizes
0013  * and/or alignment.  We define compat structures which match the
0014  * 32-bit sizes/alignments here, and their associated ioctl numbers.
0015  *
0016  * xfs_ioctl32.c contains routines to copy these structures in and out.
0017  */
0018 
0019 /* stock kernel-level ioctls we support */
0020 #define XFS_IOC_GETVERSION_32   FS_IOC32_GETVERSION
0021 
0022 /*
0023  * On intel, even if sizes match, alignment and/or padding may differ.
0024  */
0025 #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
0026 #define BROKEN_X86_ALIGNMENT
0027 #define __compat_packed __attribute__((packed))
0028 #else
0029 #define __compat_packed
0030 #endif
0031 
0032 typedef struct compat_xfs_bstime {
0033     old_time32_t    tv_sec;     /* seconds      */
0034     __s32       tv_nsec;    /* and nanoseconds  */
0035 } compat_xfs_bstime_t;
0036 
0037 struct compat_xfs_bstat {
0038     __u64       bs_ino;     /* inode number         */
0039     __u16       bs_mode;    /* type and mode        */
0040     __u16       bs_nlink;   /* number of links      */
0041     __u32       bs_uid;     /* user id          */
0042     __u32       bs_gid;     /* group id         */
0043     __u32       bs_rdev;    /* device value         */
0044     __s32       bs_blksize; /* block size           */
0045     __s64       bs_size;    /* file size            */
0046     compat_xfs_bstime_t bs_atime;   /* access time          */
0047     compat_xfs_bstime_t bs_mtime;   /* modify time          */
0048     compat_xfs_bstime_t bs_ctime;   /* inode change time        */
0049     int64_t     bs_blocks;  /* number of blocks     */
0050     __u32       bs_xflags;  /* extended flags       */
0051     __s32       bs_extsize; /* extent size          */
0052     __s32       bs_extents; /* number of extents        */
0053     __u32       bs_gen;     /* generation count     */
0054     __u16       bs_projid_lo;   /* lower part of project id */
0055 #define bs_projid   bs_projid_lo    /* (previously just bs_projid)  */
0056     __u16       bs_forkoff; /* inode fork offset in bytes   */
0057     __u16       bs_projid_hi;   /* high part of project id  */
0058     unsigned char   bs_pad[10]; /* pad space, unused        */
0059     __u32       bs_dmevmask;    /* DMIG event mask      */
0060     __u16       bs_dmstate; /* DMIG state info      */
0061     __u16       bs_aextents;    /* attribute number of extents  */
0062 } __compat_packed;
0063 
0064 struct compat_xfs_fsop_bulkreq {
0065     compat_uptr_t   lastip;     /* last inode # pointer     */
0066     __s32       icount;     /* count of entries in buffer   */
0067     compat_uptr_t   ubuffer;    /* user buffer for inode desc.  */
0068     compat_uptr_t   ocount;     /* output count pointer     */
0069 };
0070 
0071 #define XFS_IOC_FSBULKSTAT_32 \
0072     _IOWR('X', 101, struct compat_xfs_fsop_bulkreq)
0073 #define XFS_IOC_FSBULKSTAT_SINGLE_32 \
0074     _IOWR('X', 102, struct compat_xfs_fsop_bulkreq)
0075 #define XFS_IOC_FSINUMBERS_32 \
0076     _IOWR('X', 103, struct compat_xfs_fsop_bulkreq)
0077 
0078 typedef struct compat_xfs_fsop_handlereq {
0079     __u32       fd;     /* fd for FD_TO_HANDLE      */
0080     compat_uptr_t   path;       /* user pathname        */
0081     __u32       oflags;     /* open flags           */
0082     compat_uptr_t   ihandle;    /* user supplied handle     */
0083     __u32       ihandlen;   /* user supplied length     */
0084     compat_uptr_t   ohandle;    /* user buffer for handle   */
0085     compat_uptr_t   ohandlen;   /* user buffer length       */
0086 } compat_xfs_fsop_handlereq_t;
0087 
0088 #define XFS_IOC_PATH_TO_FSHANDLE_32 \
0089     _IOWR('X', 104, struct compat_xfs_fsop_handlereq)
0090 #define XFS_IOC_PATH_TO_HANDLE_32 \
0091     _IOWR('X', 105, struct compat_xfs_fsop_handlereq)
0092 #define XFS_IOC_FD_TO_HANDLE_32 \
0093     _IOWR('X', 106, struct compat_xfs_fsop_handlereq)
0094 #define XFS_IOC_OPEN_BY_HANDLE_32 \
0095     _IOWR('X', 107, struct compat_xfs_fsop_handlereq)
0096 #define XFS_IOC_READLINK_BY_HANDLE_32 \
0097     _IOWR('X', 108, struct compat_xfs_fsop_handlereq)
0098 
0099 /* The bstat field in the swapext struct needs translation */
0100 struct compat_xfs_swapext {
0101     int64_t         sx_version; /* version */
0102     int64_t         sx_fdtarget;    /* fd of target file */
0103     int64_t         sx_fdtmp;   /* fd of tmp file */
0104     xfs_off_t       sx_offset;  /* offset into file */
0105     xfs_off_t       sx_length;  /* leng from offset */
0106     char            sx_pad[16]; /* pad space, unused */
0107     struct compat_xfs_bstat sx_stat;    /* stat of target b4 copy */
0108 } __compat_packed;
0109 
0110 #define XFS_IOC_SWAPEXT_32  _IOWR('X', 109, struct compat_xfs_swapext)
0111 
0112 typedef struct compat_xfs_fsop_attrlist_handlereq {
0113     struct compat_xfs_fsop_handlereq hreq; /* handle interface structure */
0114     struct xfs_attrlist_cursor  pos; /* opaque cookie, list offset */
0115     __u32               flags;  /* which namespace to use */
0116     __u32               buflen; /* length of buffer supplied */
0117     compat_uptr_t           buffer; /* returned names */
0118 } __compat_packed compat_xfs_fsop_attrlist_handlereq_t;
0119 
0120 /* Note: actually this is read/write */
0121 #define XFS_IOC_ATTRLIST_BY_HANDLE_32 \
0122     _IOW('X', 122, struct compat_xfs_fsop_attrlist_handlereq)
0123 
0124 /* am_opcodes defined in xfs_fs.h */
0125 typedef struct compat_xfs_attr_multiop {
0126     __u32       am_opcode;
0127     __s32       am_error;
0128     compat_uptr_t   am_attrname;
0129     compat_uptr_t   am_attrvalue;
0130     __u32       am_length;
0131     __u32       am_flags;
0132 } compat_xfs_attr_multiop_t;
0133 
0134 typedef struct compat_xfs_fsop_attrmulti_handlereq {
0135     struct compat_xfs_fsop_handlereq hreq; /* handle interface structure */
0136     __u32               opcount;/* count of following multiop */
0137     /* ptr to compat_xfs_attr_multiop */
0138     compat_uptr_t           ops; /* attr_multi data */
0139 } compat_xfs_fsop_attrmulti_handlereq_t;
0140 
0141 #define XFS_IOC_ATTRMULTI_BY_HANDLE_32 \
0142     _IOW('X', 123, struct compat_xfs_fsop_attrmulti_handlereq)
0143 
0144 #ifdef BROKEN_X86_ALIGNMENT
0145 typedef struct compat_xfs_fsop_geom_v1 {
0146     __u32       blocksize;  /* filesystem (data) block size */
0147     __u32       rtextsize;  /* realtime extent size     */
0148     __u32       agblocks;   /* fsblocks in an AG        */
0149     __u32       agcount;    /* number of allocation groups  */
0150     __u32       logblocks;  /* fsblocks in the log      */
0151     __u32       sectsize;   /* (data) sector size, bytes    */
0152     __u32       inodesize;  /* inode size in bytes      */
0153     __u32       imaxpct;    /* max allowed inode space(%)   */
0154     __u64       datablocks; /* fsblocks in data subvolume   */
0155     __u64       rtblocks;   /* fsblocks in realtime subvol  */
0156     __u64       rtextents;  /* rt extents in realtime subvol*/
0157     __u64       logstart;   /* starting fsblock of the log  */
0158     unsigned char   uuid[16];   /* unique id of the filesystem  */
0159     __u32       sunit;      /* stripe unit, fsblocks    */
0160     __u32       swidth;     /* stripe width, fsblocks   */
0161     __s32       version;    /* structure version        */
0162     __u32       flags;      /* superblock version flags */
0163     __u32       logsectsize;    /* log sector size, bytes   */
0164     __u32       rtsectsize; /* realtime sector size, bytes  */
0165     __u32       dirblocksize;   /* directory block size, bytes  */
0166 } __attribute__((packed)) compat_xfs_fsop_geom_v1_t;
0167 
0168 #define XFS_IOC_FSGEOMETRY_V1_32  \
0169     _IOR('X', 100, struct compat_xfs_fsop_geom_v1)
0170 
0171 struct compat_xfs_inogrp {
0172     __u64       xi_startino;    /* starting inode number    */
0173     __s32       xi_alloccount;  /* # bits set in allocmask  */
0174     __u64       xi_allocmask;   /* mask of allocated inodes */
0175 } __attribute__((packed));
0176 
0177 /* These growfs input structures have padding on the end, so must translate */
0178 typedef struct compat_xfs_growfs_data {
0179     __u64       newblocks;  /* new data subvol size, fsblocks */
0180     __u32       imaxpct;    /* new inode space percentage limit */
0181 } __attribute__((packed)) compat_xfs_growfs_data_t;
0182 
0183 typedef struct compat_xfs_growfs_rt {
0184     __u64       newblocks;  /* new realtime size, fsblocks */
0185     __u32       extsize;    /* new realtime extent size, fsblocks */
0186 } __attribute__((packed)) compat_xfs_growfs_rt_t;
0187 
0188 #define XFS_IOC_FSGROWFSDATA_32 _IOW('X', 110, struct compat_xfs_growfs_data)
0189 #define XFS_IOC_FSGROWFSRT_32   _IOW('X', 112, struct compat_xfs_growfs_rt)
0190 
0191 #endif /* BROKEN_X86_ALIGNMENT */
0192 
0193 #endif /* __XFS_IOCTL32_H__ */