You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[PATCH] introduce fmode_t, do annotations
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
+4
-3
@@ -173,7 +173,7 @@ unlock:
|
||||
|
||||
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);
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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))
|
||||
|
||||
+3
-2
@@ -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];
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -338,7 +338,7 @@ 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;
|
||||
@@ -346,7 +346,7 @@ nvram_open(struct inode *inode, struct file *file)
|
||||
|
||||
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++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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)))
|
||||
|
||||
@@ -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;
|
||||
|
||||
+5
-5
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
/*
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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.
|
||||
|
||||
+2
-2
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user