mirror of https://github.com/vitalif/e2fsprogs
Use consistent e2fsprogs-standard types
Some different types such as u_int16_t and __uint32_t have snuck into e2fsprogs. These types are not guaranteed by any standard, and they are not provided by dietlibc. Convert them to __u16, __u32, etc. since these are guaranteed to be provided by e2fsprogs' build. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>maint-test
parent
6c59a665da
commit
795c02def3
|
@ -931,10 +931,10 @@ static errcode_t unix_discard(io_channel channel, unsigned long long block,
|
|||
|
||||
if (channel->flags & CHANNEL_FLAGS_BLOCK_DEVICE) {
|
||||
#ifdef BLKDISCARD
|
||||
__uint64_t range[2];
|
||||
__u64 range[2];
|
||||
|
||||
range[0] = (__uint64_t)(block) * channel->block_size;
|
||||
range[1] = (__uint64_t)(count) * channel->block_size;
|
||||
range[0] = (__u64)(block) * channel->block_size;
|
||||
range[1] = (__u64)(count) * channel->block_size;
|
||||
|
||||
ret = ioctl(data->dev, BLKDISCARD, &range);
|
||||
#else
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
#ifndef __QUOTA_COMMON_H__
|
||||
#define __QUOTA_COMMON_H__
|
||||
|
||||
#if EXT2_FLAT_INCLUDES
|
||||
#include "e2_types.h"
|
||||
#else
|
||||
#include <ext2fs/ext2_types.h>
|
||||
#endif /* EXT2_FLAT_INCLUDES */
|
||||
|
||||
|
||||
#ifndef __attribute__
|
||||
# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
|
|
|
@ -30,8 +30,8 @@ static const char * const basenames[] = {
|
|||
|
||||
/* Header in all newer quotafiles */
|
||||
struct disk_dqheader {
|
||||
u_int32_t dqh_magic;
|
||||
u_int32_t dqh_version;
|
||||
__u32 dqh_magic;
|
||||
__u32 dqh_version;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ static inline void mark_quotafile_info_dirty(struct quota_handle *h)
|
|||
}
|
||||
|
||||
/* Read given block */
|
||||
static void read_blk(struct quota_handle *h, uint blk, dqbuf_t buf)
|
||||
static void read_blk(struct quota_handle *h, unsigned int blk, dqbuf_t buf)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -72,7 +72,7 @@ static void read_blk(struct quota_handle *h, uint blk, dqbuf_t buf)
|
|||
}
|
||||
|
||||
/* Write block */
|
||||
static int write_blk(struct quota_handle *h, uint blk, dqbuf_t buf)
|
||||
static int write_blk(struct quota_handle *h, unsigned int blk, dqbuf_t buf)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -117,7 +117,8 @@ static int get_free_dqblk(struct quota_handle *h)
|
|||
}
|
||||
|
||||
/* Put given block to free list */
|
||||
static void put_free_dqblk(struct quota_handle *h, dqbuf_t buf, uint blk)
|
||||
static void put_free_dqblk(struct quota_handle *h, dqbuf_t buf,
|
||||
unsigned int blk)
|
||||
{
|
||||
struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
|
||||
struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
|
||||
|
@ -131,11 +132,12 @@ static void put_free_dqblk(struct quota_handle *h, dqbuf_t buf, uint blk)
|
|||
}
|
||||
|
||||
/* Remove given block from the list of blocks with free entries */
|
||||
static void remove_free_dqentry(struct quota_handle *h, dqbuf_t buf, uint blk)
|
||||
static void remove_free_dqentry(struct quota_handle *h, dqbuf_t buf,
|
||||
unsigned int blk)
|
||||
{
|
||||
dqbuf_t tmpbuf = getdqbuf();
|
||||
struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
|
||||
uint nextblk = ext2fs_le32_to_cpu(dh->dqdh_next_free), prevblk =
|
||||
unsigned int nextblk = ext2fs_le32_to_cpu(dh->dqdh_next_free), prevblk =
|
||||
|
||||
ext2fs_le32_to_cpu(dh->dqdh_prev_free);
|
||||
|
||||
|
@ -164,7 +166,8 @@ static void remove_free_dqentry(struct quota_handle *h, dqbuf_t buf, uint blk)
|
|||
}
|
||||
|
||||
/* Insert given block to the beginning of list with free entries */
|
||||
static void insert_free_dqentry(struct quota_handle *h, dqbuf_t buf, uint blk)
|
||||
static void insert_free_dqentry(struct quota_handle *h, dqbuf_t buf,
|
||||
unsigned int blk)
|
||||
{
|
||||
dqbuf_t tmpbuf = getdqbuf();
|
||||
struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
|
||||
|
@ -188,8 +191,8 @@ static void insert_free_dqentry(struct quota_handle *h, dqbuf_t buf, uint blk)
|
|||
}
|
||||
|
||||
/* Find space for dquot */
|
||||
static uint find_free_dqentry(struct quota_handle *h, struct dquot *dquot,
|
||||
int *err)
|
||||
static unsigned int find_free_dqentry(struct quota_handle *h,
|
||||
struct dquot *dquot, int *err)
|
||||
{
|
||||
int blk, i;
|
||||
struct qt_disk_dqdbheader *dh;
|
||||
|
@ -247,12 +250,12 @@ static uint find_free_dqentry(struct quota_handle *h, struct dquot *dquot,
|
|||
|
||||
/* Insert reference to structure into the trie */
|
||||
static int do_insert_tree(struct quota_handle *h, struct dquot *dquot,
|
||||
uint * treeblk, int depth)
|
||||
unsigned int * treeblk, int depth)
|
||||
{
|
||||
dqbuf_t buf;
|
||||
int newson = 0, newact = 0;
|
||||
u_int32_t *ref;
|
||||
uint newblk;
|
||||
__u32 *ref;
|
||||
unsigned int newblk;
|
||||
int ret = 0;
|
||||
|
||||
log_debug("inserting in tree: treeblk=%u, depth=%d", *treeblk, depth);
|
||||
|
@ -271,7 +274,7 @@ static int do_insert_tree(struct quota_handle *h, struct dquot *dquot,
|
|||
read_blk(h, *treeblk, buf);
|
||||
}
|
||||
|
||||
ref = (u_int32_t *) buf;
|
||||
ref = (__u32 *) buf;
|
||||
newblk = ext2fs_le32_to_cpu(ref[get_index(dquot->dq_id, depth)]);
|
||||
if (!newblk)
|
||||
newson = 1;
|
||||
|
@ -301,11 +304,11 @@ out_buf:
|
|||
/* Wrapper for inserting quota structure into tree */
|
||||
static void dq_insert_tree(struct quota_handle *h, struct dquot *dquot)
|
||||
{
|
||||
uint tmp = QT_TREEOFF;
|
||||
unsigned int tmp = QT_TREEOFF;
|
||||
|
||||
if (do_insert_tree(h, dquot, &tmp, 0) < 0)
|
||||
log_err("Cannot write quota (id %u): %s",
|
||||
(uint) dquot->dq_id, strerror(errno));
|
||||
(unsigned int) dquot->dq_id, strerror(errno));
|
||||
}
|
||||
|
||||
/* Write dquot to file */
|
||||
|
@ -323,7 +326,7 @@ void qtree_write_dquot(struct dquot *dquot)
|
|||
if (ret) {
|
||||
errno = ENOMEM;
|
||||
log_err("Quota write failed (id %u): %s",
|
||||
(uint)dquot->dq_id, strerror(errno));
|
||||
(unsigned int)dquot->dq_id, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -340,13 +343,14 @@ void qtree_write_dquot(struct dquot *dquot)
|
|||
if (ret > 0)
|
||||
errno = ENOSPC;
|
||||
log_err("Quota write failed (id %u): %s",
|
||||
(uint)dquot->dq_id, strerror(errno));
|
||||
(unsigned int)dquot->dq_id, strerror(errno));
|
||||
}
|
||||
ext2fs_free_mem(&ddquot);
|
||||
}
|
||||
|
||||
/* Free dquot entry in data block */
|
||||
static void free_dqentry(struct quota_handle *h, struct dquot *dquot, uint blk)
|
||||
static void free_dqentry(struct quota_handle *h, struct dquot *dquot,
|
||||
unsigned int blk)
|
||||
{
|
||||
struct qt_disk_dqdbheader *dh;
|
||||
struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
|
||||
|
@ -358,7 +362,7 @@ static void free_dqentry(struct quota_handle *h, struct dquot *dquot, uint blk)
|
|||
if (dquot->dq_dqb.u.v2_mdqb.dqb_off >> QT_BLKSIZE_BITS != blk)
|
||||
log_err("Quota structure has offset to other block (%u) "
|
||||
"than it should (%u).", blk,
|
||||
(uint) (dquot->dq_dqb.u.v2_mdqb.dqb_off >>
|
||||
(unsigned int) (dquot->dq_dqb.u.v2_mdqb.dqb_off >>
|
||||
QT_BLKSIZE_BITS));
|
||||
|
||||
read_blk(h, blk, buf);
|
||||
|
@ -388,11 +392,11 @@ static void free_dqentry(struct quota_handle *h, struct dquot *dquot, uint blk)
|
|||
|
||||
/* Remove reference to dquot from tree */
|
||||
static void remove_tree(struct quota_handle *h, struct dquot *dquot,
|
||||
uint * blk, int depth)
|
||||
unsigned int * blk, int depth)
|
||||
{
|
||||
dqbuf_t buf = getdqbuf();
|
||||
uint newblk;
|
||||
u_int32_t *ref = (u_int32_t *) buf;
|
||||
unsigned int newblk;
|
||||
__u32 *ref = (__u32 *) buf;
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
|
@ -428,7 +432,7 @@ static void remove_tree(struct quota_handle *h, struct dquot *dquot,
|
|||
/* Delete dquot from tree */
|
||||
void qtree_delete_dquot(struct dquot *dquot)
|
||||
{
|
||||
uint tmp = QT_TREEOFF;
|
||||
unsigned int tmp = QT_TREEOFF;
|
||||
|
||||
if (!dquot->dq_dqb.u.v2_mdqb.dqb_off) /* Even not allocated? */
|
||||
return;
|
||||
|
@ -437,7 +441,7 @@ void qtree_delete_dquot(struct dquot *dquot)
|
|||
|
||||
/* Find entry in block */
|
||||
static ext2_loff_t find_block_dqentry(struct quota_handle *h,
|
||||
struct dquot *dquot, uint blk)
|
||||
struct dquot *dquot, unsigned int blk)
|
||||
{
|
||||
struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
|
||||
dqbuf_t buf = getdqbuf();
|
||||
|
@ -464,11 +468,11 @@ static ext2_loff_t find_block_dqentry(struct quota_handle *h,
|
|||
/* Find entry for given id in the tree */
|
||||
static ext2_loff_t find_tree_dqentry(struct quota_handle *h,
|
||||
struct dquot *dquot,
|
||||
uint blk, int depth)
|
||||
unsigned int blk, int depth)
|
||||
{
|
||||
dqbuf_t buf = getdqbuf();
|
||||
ext2_loff_t ret = 0;
|
||||
u_int32_t *ref = (u_int32_t *) buf;
|
||||
__u32 *ref = (__u32 *) buf;
|
||||
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
@ -540,7 +544,7 @@ struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id)
|
|||
#define set_bit(bmp, ind) ((bmp)[(ind) >> 3] |= (1 << ((ind) & 7)))
|
||||
#define get_bit(bmp, ind) ((bmp)[(ind) >> 3] & (1 << ((ind) & 7)))
|
||||
|
||||
static int report_block(struct dquot *dquot, uint blk, char *bitmap,
|
||||
static int report_block(struct dquot *dquot, unsigned int blk, char *bitmap,
|
||||
int (*process_dquot) (struct dquot *, void *),
|
||||
void *data)
|
||||
{
|
||||
|
@ -574,7 +578,7 @@ static int report_block(struct dquot *dquot, uint blk, char *bitmap,
|
|||
return entries;
|
||||
}
|
||||
|
||||
static void check_reference(struct quota_handle *h, uint blk)
|
||||
static void check_reference(struct quota_handle *h, unsigned int blk)
|
||||
{
|
||||
if (blk >= h->qh_info.u.v2_mdqi.dqi_qtree.dqi_blocks)
|
||||
log_err("Illegal reference (%u >= %u) in %s quota file. "
|
||||
|
@ -585,13 +589,14 @@ static void check_reference(struct quota_handle *h, uint blk)
|
|||
type2name(h->qh_type));
|
||||
}
|
||||
|
||||
static int report_tree(struct dquot *dquot, uint blk, int depth, char *bitmap,
|
||||
static int report_tree(struct dquot *dquot, unsigned int blk, int depth,
|
||||
char *bitmap,
|
||||
int (*process_dquot) (struct dquot *, void *),
|
||||
void *data)
|
||||
{
|
||||
int entries = 0, i;
|
||||
dqbuf_t buf = getdqbuf();
|
||||
u_int32_t *ref = (u_int32_t *) buf;
|
||||
__u32 *ref = (__u32 *) buf;
|
||||
|
||||
if (!buf)
|
||||
return 0;
|
||||
|
@ -620,9 +625,9 @@ static int report_tree(struct dquot *dquot, uint blk, int depth, char *bitmap,
|
|||
return entries;
|
||||
}
|
||||
|
||||
static uint find_set_bits(char *bmp, int blocks)
|
||||
static unsigned int find_set_bits(char *bmp, int blocks)
|
||||
{
|
||||
uint i, used = 0;
|
||||
unsigned int i, used = 0;
|
||||
|
||||
for (i = 0; i < blocks; i++)
|
||||
if (get_bit(bmp, i))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef u_int32_t qid_t; /* Type in which we store ids in memory */
|
||||
typedef __u32 qid_t; /* Type in which we store ids in memory */
|
||||
|
||||
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
|
||||
#define QT_TREEDEPTH 4 /* Depth of quota tree */
|
||||
|
@ -20,13 +20,13 @@ typedef u_int32_t qid_t; /* Type in which we store ids in memory */
|
|||
* so there will be space for exactly 21 quota-entries in a block
|
||||
*/
|
||||
struct qt_disk_dqdbheader {
|
||||
u_int32_t dqdh_next_free; /* Number of next block with free
|
||||
__u32 dqdh_next_free; /* Number of next block with free
|
||||
* entry */
|
||||
u_int32_t dqdh_prev_free; /* Number of previous block with free
|
||||
__u32 dqdh_prev_free; /* Number of previous block with free
|
||||
* entry */
|
||||
u_int16_t dqdh_entries; /* Number of valid entries in block */
|
||||
u_int16_t dqdh_pad1;
|
||||
u_int32_t dqdh_pad2;
|
||||
__u16 dqdh_entries; /* Number of valid entries in block */
|
||||
__u16 dqdh_pad1;
|
||||
__u32 dqdh_pad2;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct dquot;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#define V2_VERSION 1
|
||||
|
||||
struct v2_disk_dqheader {
|
||||
u_int32_t dqh_magic; /* Magic number identifying file */
|
||||
u_int32_t dqh_version; /* File version */
|
||||
__u32 dqh_magic; /* Magic number identifying file */
|
||||
__u32 dqh_version; /* File version */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Flags for version specific files */
|
||||
|
@ -25,30 +25,30 @@ struct v2_disk_dqheader {
|
|||
|
||||
/* Header with type and version specific information */
|
||||
struct v2_disk_dqinfo {
|
||||
u_int32_t dqi_bgrace; /* Time before block soft limit becomes
|
||||
__u32 dqi_bgrace; /* Time before block soft limit becomes
|
||||
* hard limit */
|
||||
u_int32_t dqi_igrace; /* Time before inode soft limit becomes
|
||||
__u32 dqi_igrace; /* Time before inode soft limit becomes
|
||||
* hard limit */
|
||||
u_int32_t dqi_flags; /* Flags for quotafile (DQF_*) */
|
||||
u_int32_t dqi_blocks; /* Number of blocks in file */
|
||||
u_int32_t dqi_free_blk; /* Number of first free block in the list */
|
||||
u_int32_t dqi_free_entry; /* Number of block with at least one
|
||||
__u32 dqi_flags; /* Flags for quotafile (DQF_*) */
|
||||
__u32 dqi_blocks; /* Number of blocks in file */
|
||||
__u32 dqi_free_blk; /* Number of first free block in the list */
|
||||
__u32 dqi_free_entry; /* Number of block with at least one
|
||||
* free entry */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct v2r1_disk_dqblk {
|
||||
u_int32_t dqb_id; /* id this quota applies to */
|
||||
u_int32_t dqb_pad;
|
||||
u_int64_t dqb_ihardlimit; /* absolute limit on allocated inodes */
|
||||
u_int64_t dqb_isoftlimit; /* preferred inode limit */
|
||||
u_int64_t dqb_curinodes; /* current # allocated inodes */
|
||||
u_int64_t dqb_bhardlimit; /* absolute limit on disk space
|
||||
__u32 dqb_id; /* id this quota applies to */
|
||||
__u32 dqb_pad;
|
||||
__u64 dqb_ihardlimit; /* absolute limit on allocated inodes */
|
||||
__u64 dqb_isoftlimit; /* preferred inode limit */
|
||||
__u64 dqb_curinodes; /* current # allocated inodes */
|
||||
__u64 dqb_bhardlimit; /* absolute limit on disk space
|
||||
* (in QUOTABLOCK_SIZE) */
|
||||
u_int64_t dqb_bsoftlimit; /* preferred limit on disk space
|
||||
__u64 dqb_bsoftlimit; /* preferred limit on disk space
|
||||
* (in QUOTABLOCK_SIZE) */
|
||||
u_int64_t dqb_curspace; /* current space occupied (in bytes) */
|
||||
u_int64_t dqb_btime; /* time limit for excessive disk use */
|
||||
u_int64_t dqb_itime; /* time limit for excessive inode use */
|
||||
__u64 dqb_curspace; /* current space occupied (in bytes) */
|
||||
__u64 dqb_btime; /* time limit for excessive disk use */
|
||||
__u64 dqb_itime; /* time limit for excessive inode use */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue