Skip to content

Commit

Permalink
[PATCH] introduce fmode_t, do annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Oct 21, 2008
1 parent 2515ddc commit aeb5d72
Show file tree
Hide file tree
Showing 41 changed files with 96 additions and 98 deletions.
7 changes: 4 additions & 3 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static int bsg_io_schedule(struct bsg_device *bd)

static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
struct sg_io_v4 *hdr, struct bsg_device *bd,
int has_write_perm)
fmode_t has_write_perm)
{
if (hdr->request_len > BLK_MAX_CDB) {
rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
Expand Down Expand Up @@ -242,7 +242,7 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
* map sg_io_v4 to a request.
*/
static struct request *
bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, int has_write_perm)
bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
{
struct request_queue *q = bd->queue;
struct request *rq, *next_rq = NULL;
Expand Down Expand Up @@ -601,7 +601,8 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
}

static int __bsg_write(struct bsg_device *bd, const char __user *buf,
size_t count, ssize_t *bytes_written, int has_write_perm)
size_t count, ssize_t *bytes_written,
fmode_t has_write_perm)
{
struct bsg_command *bc;
struct request *rq;
Expand Down
2 changes: 1 addition & 1 deletion block/cmd-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <linux/cdrom.h>

int blk_verify_command(struct blk_cmd_filter *filter,
unsigned char *cmd, int has_write_perm)
unsigned char *cmd, fmode_t has_write_perm)
{
/* root can do any command. */
if (capable(CAP_SYS_RAWIO))
Expand Down
5 changes: 3 additions & 2 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ int sg_scsi_ioctl(struct file *file, struct request_queue *q,
struct gendisk *disk, struct scsi_ioctl_command __user *sic)
{
struct request *rq;
int err, write_perm = 0;
int err;
fmode_t write_perm = 0;
unsigned int in_len, out_len, bytes, opcode, cmdlen;
char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];

Expand Down Expand Up @@ -428,7 +429,7 @@ int sg_scsi_ioctl(struct file *file, struct request_queue *q,

/* scsi_ioctl passes NULL */
if (file && (file->f_mode & FMODE_WRITE))
write_perm = 1;
write_perm = FMODE_WRITE;

err = blk_verify_command(&q->cmd_filter, rq->cmd, write_perm);
if (err)
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/amiflop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,9 +1560,9 @@ static int floppy_open(struct inode *inode, struct file *filp)
if (fd_ref[drive] && old_dev != system)
return -EBUSY;

if (filp && filp->f_mode & 3) {
if (filp && filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
check_disk_change(inode->i_bdev);
if (filp->f_mode & 2 ) {
if (filp->f_mode & FMODE_WRITE ) {
int wrprot;

get_fdc(drive);
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/ataflop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,9 +1826,9 @@ static int floppy_open( struct inode *inode, struct file *filp )
if (filp->f_flags & O_NDELAY)
return 0;

if (filp->f_mode & 3) {
if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
check_disk_change(inode->i_bdev);
if (filp->f_mode & 2) {
if (filp->f_mode & FMODE_WRITE) {
if (p->wpstat) {
if (p->ref < 0)
p->ref = 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3761,14 +3761,14 @@ static int floppy_open(struct inode *inode, struct file *filp)
UFDCS->rawcmd = 2;

if (!(filp->f_flags & O_NDELAY)) {
if (filp->f_mode & 3) {
if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
UDRS->last_checked = 0;
check_disk_change(inode->i_bdev);
if (UTESTF(FD_DISK_CHANGED))
goto out;
}
res = -EROFS;
if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
if ((filp->f_mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
goto out;
}
mutex_unlock(&open_lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/paride/pf.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static int pf_open(struct inode *inode, struct file *file)
if (pf->media_status == PF_NM)
return -ENODEV;

if ((pf->media_status == PF_RO) && (file->f_mode & 2))
if ((pf->media_status == PF_RO) && (file->f_mode & FMODE_WRITE))
return -EROFS;

pf->access++;
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/paride/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ static int pt_open(struct inode *inode, struct file *file)
goto out;

err = -EROFS;
if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2))
if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE))
goto out;

if (!(iminor(inode) & 128))
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2320,7 +2320,7 @@ static int pkt_open_write(struct pktcdvd_device *pd)
/*
* called at open time.
*/
static int pkt_open_dev(struct pktcdvd_device *pd, int write)
static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
{
int ret;
long lba;
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/swim3.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,13 +908,13 @@ static int floppy_open(struct inode *inode, struct file *filp)
return -EBUSY;

if (err == 0 && (filp->f_flags & O_NDELAY) == 0
&& (filp->f_mode & 3)) {
&& (filp->f_mode & (FMODE_READ|FMODE_WRITE))) {
check_disk_change(inode->i_bdev);
if (fs->ejected)
err = -ENXIO;
}

if (err == 0 && (filp->f_mode & 2)) {
if (err == 0 && (filp->f_mode & FMODE_WRITE)) {
if (fs->write_prot < 0)
fs->write_prot = swim3_readbit(fs, WRITE_PROT);
if (fs->write_prot)
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ nvram_open(struct inode *inode, struct file *file)

if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
(nvram_open_mode & NVRAM_EXCL) ||
((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) {
((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) {
spin_unlock(&nvram_state_lock);
unlock_kernel();
return -EBUSY;
}

if (file->f_flags & O_EXCL)
nvram_open_mode |= NVRAM_EXCL;
if (file->f_mode & 2)
if (file->f_mode & FMODE_WRITE)
nvram_open_mode |= NVRAM_WRITE;
nvram_open_cnt++;

Expand All @@ -366,7 +366,7 @@ nvram_release(struct inode *inode, struct file *file)
/* if only one instance is open, clear the EXCL bit */
if (nvram_open_mode & NVRAM_EXCL)
nvram_open_mode &= ~NVRAM_EXCL;
if (file->f_mode & 2)
if (file->f_mode & FMODE_WRITE)
nvram_open_mode &= ~NVRAM_WRITE;

spin_unlock(&nvram_state_lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-floppy_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
return ide_floppy_get_format_capacities(drive, argp);
case IDEFLOPPY_IOCTL_FORMAT_START:
if (!(file->f_mode & 2))
if (!(file->f_mode & FMODE_WRITE))
return -EPERM;
return ide_floppy_format_unit(drive, (int __user *)argp);
case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static int ide_gd_open(struct inode *inode, struct file *filp)
goto out_put_idkp;
}

if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & 2)) {
if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & FMODE_WRITE)) {
ret = -EROFS;
goto out_put_idkp;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,9 +988,9 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size)
return r;
}

static inline int get_mode(struct dm_ioctl *param)
static inline fmode_t get_mode(struct dm_ioctl *param)
{
int mode = FMODE_READ | FMODE_WRITE;
fmode_t mode = FMODE_READ | FMODE_WRITE;

if (param->flags & DM_READONLY_FLAG)
mode = FMODE_READ;
Expand Down
12 changes: 6 additions & 6 deletions drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct dm_table {
* device. This should be a combination of FMODE_READ
* and FMODE_WRITE.
*/
int mode;
fmode_t mode;

/* a list of devices used by this table */
struct list_head devices;
Expand Down Expand Up @@ -217,7 +217,7 @@ static int alloc_targets(struct dm_table *t, unsigned int num)
return 0;
}

int dm_table_create(struct dm_table **result, int mode,
int dm_table_create(struct dm_table **result, fmode_t mode,
unsigned num_targets, struct mapped_device *md)
{
struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
Expand Down Expand Up @@ -395,7 +395,7 @@ static int check_device_area(struct dm_dev_internal *dd, sector_t start,
* careful to leave things as they were if we fail to reopen the
* device.
*/
static int upgrade_mode(struct dm_dev_internal *dd, int new_mode,
static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode,
struct mapped_device *md)
{
int r;
Expand All @@ -421,7 +421,7 @@ static int upgrade_mode(struct dm_dev_internal *dd, int new_mode,
*/
static int __table_get_device(struct dm_table *t, struct dm_target *ti,
const char *path, sector_t start, sector_t len,
int mode, struct dm_dev **result)
fmode_t mode, struct dm_dev **result)
{
int r;
dev_t uninitialized_var(dev);
Expand Down Expand Up @@ -537,7 +537,7 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
EXPORT_SYMBOL_GPL(dm_set_device_limits);

int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
sector_t len, int mode, struct dm_dev **result)
sector_t len, fmode_t mode, struct dm_dev **result)
{
int r = __table_get_device(ti->table, ti, path,
start, len, mode, result);
Expand Down Expand Up @@ -887,7 +887,7 @@ struct list_head *dm_table_get_devices(struct dm_table *t)
return &t->devices;
}

int dm_table_get_mode(struct dm_table *t)
fmode_t dm_table_get_mode(struct dm_table *t)
{
return t->mode;
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/mtd/mtdchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static int mtd_open(struct inode *inode, struct file *file)
return -ENODEV;

/* You can't open the RO devices RW */
if ((file->f_mode & 2) && (minor & 1))
if ((file->f_mode & FMODE_WRITE) && (minor & 1))
return -EACCES;

lock_kernel();
Expand All @@ -114,7 +114,7 @@ static int mtd_open(struct inode *inode, struct file *file)
}

/* You can't open it RW if it's not a writeable device */
if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) {
put_mtd_device(mtd);
ret = -EACCES;
goto out;
Expand Down Expand Up @@ -144,7 +144,7 @@ static int mtd_close(struct inode *inode, struct file *file)
DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");

/* Only sync if opened RW */
if ((file->f_mode & 2) && mtd->sync)
if ((file->f_mode & FMODE_WRITE) && mtd->sync)
mtd->sync(mtd);

put_mtd_device(mtd);
Expand Down Expand Up @@ -443,7 +443,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
{
struct erase_info *erase;

if(!(file->f_mode & 2))
if(!(file->f_mode & FMODE_WRITE))
return -EPERM;

erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL);
Expand Down Expand Up @@ -497,7 +497,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
struct mtd_oob_buf __user *user_buf = argp;
uint32_t retlen;

if(!(file->f_mode & 2))
if(!(file->f_mode & FMODE_WRITE))
return -EPERM;

if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
Expand Down
2 changes: 1 addition & 1 deletion drivers/parisc/eisa_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int eisa_eeprom_open(struct inode *inode, struct file *file)
{
cycle_kernel_lock();

if (file->f_mode & 2)
if (file->f_mode & FMODE_WRITE)
return -EINVAL;

return 0;
Expand Down
10 changes: 5 additions & 5 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ EXPORT_SYMBOL_GPL(bd_release_from_disk);
* to be used for internal purposes. If you ever need it - reconsider
* your API.
*/
struct block_device *open_by_devnum(dev_t dev, unsigned mode)
struct block_device *open_by_devnum(dev_t dev, fmode_t mode)
{
struct block_device *bdev = bdget(dev);
int err = -ENOMEM;
Expand Down Expand Up @@ -975,7 +975,7 @@ void bd_set_size(struct block_device *bdev, loff_t size)
}
EXPORT_SYMBOL(bd_set_size);

static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
int for_part);
static int __blkdev_put(struct block_device *bdev, int for_part);

Expand Down Expand Up @@ -1104,7 +1104,7 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
return ret;
}

static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
int for_part)
{
/*
Expand All @@ -1123,7 +1123,7 @@ static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
return do_open(bdev, &fake_file, for_part);
}

int blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags)
int blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags)
{
return __blkdev_get(bdev, mode, flags, 0);
}
Expand Down Expand Up @@ -1315,7 +1315,7 @@ EXPORT_SYMBOL(lookup_bdev);
struct block_device *open_bdev_excl(const char *path, int flags, void *holder)
{
struct block_device *bdev;
mode_t mode = FMODE_READ;
fmode_t mode = FMODE_READ;
int error = 0;

bdev = lookup_bdev(path);
Expand Down
6 changes: 3 additions & 3 deletions fs/fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
filp->f_mode &= (FMODE_READ | FMODE_WRITE);

switch (filp->f_mode) {
case 1:
case FMODE_READ:
/*
* O_RDONLY
* POSIX.1 says that O_NONBLOCK means return with the FIFO
Expand All @@ -76,7 +76,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
}
break;

case 2:
case FMODE_WRITE:
/*
* O_WRONLY
* POSIX.1 says that O_NONBLOCK means return -1 with
Expand All @@ -98,7 +98,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
}
break;

case 3:
case FMODE_READ | FMODE_WRITE:
/*
* O_RDWR
* POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
Expand Down
4 changes: 2 additions & 2 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ EXPORT_SYMBOL(get_empty_filp);
* code should be moved into this function.
*/
struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry,
mode_t mode, const struct file_operations *fop)
fmode_t mode, const struct file_operations *fop)
{
struct file *file;
struct path;
Expand Down Expand Up @@ -193,7 +193,7 @@ EXPORT_SYMBOL(alloc_file);
* of this should be moving to alloc_file().
*/
int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry,
mode_t mode, const struct file_operations *fop)
fmode_t mode, const struct file_operations *fop)
{
int error = 0;
file->f_path.dentry = dentry;
Expand Down
Loading

0 comments on commit aeb5d72

Please sign in to comment.