Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
0002 /*
0003  * Copyright (c) 1995-2001,2004 Silicon Graphics, Inc.  All Rights Reserved.
0004  *
0005  * This program is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public License
0007  * as published by the Free Software Foundation.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  * GNU Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesset General Public License
0015  * along with this program; if not, write to the Free Software Foundation,
0016  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0017  */
0018 #ifndef _LINUX_DQBLK_XFS_H
0019 #define _LINUX_DQBLK_XFS_H
0020 
0021 #include <linux/types.h>
0022 
0023 /*
0024  * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
0025  */
0026 
0027 #define XQM_CMD(x)  (('X'<<8)+(x))  /* note: forms first QCMD argument */
0028 #define XQM_COMMAND(x)  (((x) & (0xff<<8)) == ('X'<<8)) /* test if for XFS */
0029 
0030 #define XQM_USRQUOTA    0   /* system call user quota type */
0031 #define XQM_GRPQUOTA    1   /* system call group quota type */
0032 #define XQM_PRJQUOTA    2   /* system call project quota type */
0033 #define XQM_MAXQUOTAS   3
0034 
0035 #define Q_XQUOTAON  XQM_CMD(1)  /* enable accounting/enforcement */
0036 #define Q_XQUOTAOFF XQM_CMD(2)  /* disable accounting/enforcement */
0037 #define Q_XGETQUOTA XQM_CMD(3)  /* get disk limits and usage */
0038 #define Q_XSETQLIM  XQM_CMD(4)  /* set disk limits */
0039 #define Q_XGETQSTAT XQM_CMD(5)  /* get quota subsystem status */
0040 #define Q_XQUOTARM  XQM_CMD(6)  /* free disk space used by dquots */
0041 #define Q_XQUOTASYNC    XQM_CMD(7)  /* delalloc flush, updates dquots */
0042 #define Q_XGETQSTATV    XQM_CMD(8)  /* newer version of get quota */
0043 #define Q_XGETNEXTQUOTA XQM_CMD(9)  /* get disk limits and usage >= ID */
0044 
0045 /*
0046  * fs_disk_quota structure:
0047  *
0048  * This contains the current quota information regarding a user/proj/group.
0049  * It is 64-bit aligned, and all the blk units are in BBs (Basic Blocks) of
0050  * 512 bytes.
0051  */
0052 #define FS_DQUOT_VERSION    1   /* fs_disk_quota.d_version */
0053 typedef struct fs_disk_quota {
0054     __s8        d_version;  /* version of this structure */
0055     __s8        d_flags;    /* FS_{USER,PROJ,GROUP}_QUOTA */
0056     __u16       d_fieldmask;    /* field specifier */
0057     __u32       d_id;       /* user, project, or group ID */
0058     __u64       d_blk_hardlimit;/* absolute limit on disk blks */
0059     __u64       d_blk_softlimit;/* preferred limit on disk blks */
0060     __u64       d_ino_hardlimit;/* maximum # allocated inodes */
0061     __u64       d_ino_softlimit;/* preferred inode limit */
0062     __u64       d_bcount;   /* # disk blocks owned by the user */
0063     __u64       d_icount;   /* # inodes owned by the user */
0064     __s32       d_itimer;   /* Zero if within inode limits. If
0065                      * not, we refuse service at this time
0066                      * (in seconds since Unix epoch) */
0067     __s32       d_btimer;   /* similar to above; for disk blocks */
0068     __u16       d_iwarns;       /* # warnings issued wrt num inodes */
0069     __u16       d_bwarns;       /* # warnings issued wrt disk blocks */
0070     __s8        d_itimer_hi;    /* upper 8 bits of timer values */
0071     __s8        d_btimer_hi;
0072     __s8        d_rtbtimer_hi;
0073     __s8        d_padding2; /* padding2 - for future use */
0074     __u64       d_rtb_hardlimit;/* absolute limit on realtime blks */
0075     __u64       d_rtb_softlimit;/* preferred limit on RT disk blks */
0076     __u64       d_rtbcount; /* # realtime blocks owned */
0077     __s32       d_rtbtimer; /* similar to above; for RT disk blks */
0078     __u16       d_rtbwarns;     /* # warnings issued wrt RT disk blks */
0079     __s16       d_padding3; /* padding3 - for future use */ 
0080     char        d_padding4[8];  /* yet more padding */
0081 } fs_disk_quota_t;
0082 
0083 /*
0084  * These fields are sent to Q_XSETQLIM to specify fields that need to change.
0085  */
0086 #define FS_DQ_ISOFT (1<<0)
0087 #define FS_DQ_IHARD (1<<1)
0088 #define FS_DQ_BSOFT (1<<2)
0089 #define FS_DQ_BHARD     (1<<3)
0090 #define FS_DQ_RTBSOFT   (1<<4)
0091 #define FS_DQ_RTBHARD   (1<<5)
0092 #define FS_DQ_LIMIT_MASK    (FS_DQ_ISOFT | FS_DQ_IHARD | FS_DQ_BSOFT | \
0093                  FS_DQ_BHARD | FS_DQ_RTBSOFT | FS_DQ_RTBHARD)
0094 /*
0095  * These timers can only be set in super user's dquot. For others, timers are
0096  * automatically started and stopped. Superusers timer values set the limits
0097  * for the rest.  In case these values are zero, the DQ_{F,B}TIMELIMIT values
0098  * defined below are used. 
0099  * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
0100  */
0101 #define FS_DQ_BTIMER    (1<<6)
0102 #define FS_DQ_ITIMER    (1<<7)
0103 #define FS_DQ_RTBTIMER  (1<<8)
0104 #define FS_DQ_TIMER_MASK    (FS_DQ_BTIMER | FS_DQ_ITIMER | FS_DQ_RTBTIMER)
0105 
0106 /*
0107  * Warning counts are set in both super user's dquot and others. For others,
0108  * warnings are set/cleared by the administrators (or automatically by going
0109  * below the soft limit).  Superusers warning values set the warning limits
0110  * for the rest.  In case these values are zero, the DQ_{F,B}WARNLIMIT values
0111  * defined below are used. 
0112  * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
0113  */
0114 #define FS_DQ_BWARNS    (1<<9)
0115 #define FS_DQ_IWARNS    (1<<10)
0116 #define FS_DQ_RTBWARNS  (1<<11)
0117 #define FS_DQ_WARNS_MASK    (FS_DQ_BWARNS | FS_DQ_IWARNS | FS_DQ_RTBWARNS)
0118 
0119 /*
0120  * Accounting values.  These can only be set for filesystem with
0121  * non-transactional quotas that require quotacheck(8) in userspace.
0122  */
0123 #define FS_DQ_BCOUNT        (1<<12)
0124 #define FS_DQ_ICOUNT        (1<<13)
0125 #define FS_DQ_RTBCOUNT      (1<<14)
0126 #define FS_DQ_ACCT_MASK     (FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)
0127 
0128 /*
0129  * Quota expiration timestamps are 40-bit signed integers, with the upper 8
0130  * bits encoded in the _hi fields.
0131  */
0132 #define FS_DQ_BIGTIME       (1<<15)
0133 
0134 /*
0135  * Various flags related to quotactl(2).
0136  */
0137 #define FS_QUOTA_UDQ_ACCT   (1<<0)  /* user quota accounting */
0138 #define FS_QUOTA_UDQ_ENFD   (1<<1)  /* user quota limits enforcement */
0139 #define FS_QUOTA_GDQ_ACCT   (1<<2)  /* group quota accounting */
0140 #define FS_QUOTA_GDQ_ENFD   (1<<3)  /* group quota limits enforcement */
0141 #define FS_QUOTA_PDQ_ACCT   (1<<4)  /* project quota accounting */
0142 #define FS_QUOTA_PDQ_ENFD   (1<<5)  /* project quota limits enforcement */
0143 
0144 #define FS_USER_QUOTA       (1<<0)  /* user quota type */
0145 #define FS_PROJ_QUOTA       (1<<1)  /* project quota type */
0146 #define FS_GROUP_QUOTA      (1<<2)  /* group quota type */
0147 
0148 /*
0149  * fs_quota_stat is the struct returned in Q_XGETQSTAT for a given file system.
0150  * Provides a centralized way to get meta information about the quota subsystem.
0151  * eg. space taken up for user and group quotas, number of dquots currently
0152  * incore.
0153  */
0154 #define FS_QSTAT_VERSION    1   /* fs_quota_stat.qs_version */
0155 
0156 /*
0157  * Some basic information about 'quota files'.
0158  */
0159 typedef struct fs_qfilestat {
0160     __u64       qfs_ino;    /* inode number */
0161     __u64       qfs_nblks;  /* number of BBs 512-byte-blks */
0162     __u32       qfs_nextents;   /* number of extents */
0163 } fs_qfilestat_t;
0164 
0165 typedef struct fs_quota_stat {
0166     __s8        qs_version; /* version number for future changes */
0167     __u16       qs_flags;   /* FS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
0168     __s8        qs_pad;     /* unused */
0169     fs_qfilestat_t  qs_uquota;  /* user quota storage information */
0170     fs_qfilestat_t  qs_gquota;  /* group quota storage information */
0171     __u32       qs_incoredqs;   /* number of dquots incore */
0172     __s32       qs_btimelimit;  /* limit for blks timer */  
0173     __s32       qs_itimelimit;  /* limit for inodes timer */    
0174     __s32       qs_rtbtimelimit;/* limit for rt blks timer */   
0175     __u16       qs_bwarnlimit;  /* limit for num warnings */
0176     __u16       qs_iwarnlimit;  /* limit for num warnings */
0177 } fs_quota_stat_t;
0178 
0179 /*
0180  * fs_quota_statv is used by Q_XGETQSTATV for a given file system. It provides
0181  * a centralized way to get meta information about the quota subsystem. eg.
0182  * space taken up for user, group, and project quotas, number of dquots
0183  * currently incore.
0184  *
0185  * This version has proper versioning support with appropriate padding for
0186  * future expansions, and ability to expand for future without creating any
0187  * backward compatibility issues.
0188  *
0189  * Q_XGETQSTATV uses the passed in value of the requested version via
0190  * fs_quota_statv.qs_version to determine the return data layout of
0191  * fs_quota_statv.  The kernel will fill the data fields relevant to that
0192  * version.
0193  *
0194  * If kernel does not support user space caller specified version, EINVAL will
0195  * be returned. User space caller can then reduce the version number and retry
0196  * the same command.
0197  */
0198 #define FS_QSTATV_VERSION1  1   /* fs_quota_statv.qs_version */
0199 /*
0200  * Some basic information about 'quota files' for Q_XGETQSTATV command
0201  */
0202 struct fs_qfilestatv {
0203     __u64       qfs_ino;    /* inode number */
0204     __u64       qfs_nblks;  /* number of BBs 512-byte-blks */
0205     __u32       qfs_nextents;   /* number of extents */
0206     __u32       qfs_pad;    /* pad for 8-byte alignment */
0207 };
0208 
0209 struct fs_quota_statv {
0210     __s8            qs_version; /* version for future changes */
0211     __u8            qs_pad1;    /* pad for 16bit alignment */
0212     __u16           qs_flags;   /* FS_QUOTA_.* flags */
0213     __u32           qs_incoredqs;   /* number of dquots incore */
0214     struct fs_qfilestatv    qs_uquota;  /* user quota information */
0215     struct fs_qfilestatv    qs_gquota;  /* group quota information */
0216     struct fs_qfilestatv    qs_pquota;  /* project quota information */
0217     __s32           qs_btimelimit;  /* limit for blks timer */
0218     __s32           qs_itimelimit;  /* limit for inodes timer */
0219     __s32           qs_rtbtimelimit;/* limit for rt blks timer */
0220     __u16           qs_bwarnlimit;  /* limit for num warnings */
0221     __u16           qs_iwarnlimit;  /* limit for num warnings */
0222     __u16           qs_rtbwarnlimit;/* limit for rt blks warnings */
0223     __u16           qs_pad3;
0224     __u32           qs_pad4;
0225     __u64           qs_pad2[7]; /* for future proofing */
0226 };
0227 
0228 #endif  /* _LINUX_DQBLK_XFS_H */