mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev: [PATCH] fix bogus argument of blkdev_put() in pktcdvd [PATCH 2/2] documnt FMODE_ constants [PATCH 1/2] kill FMODE_NDELAY_NOW [PATCH] clean up blkdev_get a little bit [PATCH] Fix block dev compat ioctl handling [PATCH] kill obsolete temporary comment in swsusp_close()
This commit is contained in:
commit
bbeba4c35c
7 changed files with 68 additions and 27 deletions
|
@ -677,6 +677,29 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
|
|||
case DVD_WRITE_STRUCT:
|
||||
case DVD_AUTH:
|
||||
arg = (unsigned long)compat_ptr(arg);
|
||||
/* These intepret arg as an unsigned long, not as a pointer,
|
||||
* so we must not do compat_ptr() conversion. */
|
||||
case HDIO_SET_MULTCOUNT:
|
||||
case HDIO_SET_UNMASKINTR:
|
||||
case HDIO_SET_KEEPSETTINGS:
|
||||
case HDIO_SET_32BIT:
|
||||
case HDIO_SET_NOWERR:
|
||||
case HDIO_SET_DMA:
|
||||
case HDIO_SET_PIO_MODE:
|
||||
case HDIO_SET_NICE:
|
||||
case HDIO_SET_WCACHE:
|
||||
case HDIO_SET_ACOUSTIC:
|
||||
case HDIO_SET_BUSSTATE:
|
||||
case HDIO_SET_ADDRESS:
|
||||
case CDROMEJECT_SW:
|
||||
case CDROM_SET_OPTIONS:
|
||||
case CDROM_CLEAR_OPTIONS:
|
||||
case CDROM_SELECT_SPEED:
|
||||
case CDROM_SELECT_DISC:
|
||||
case CDROM_MEDIA_CHANGED:
|
||||
case CDROM_DRIVE_STATUS:
|
||||
case CDROM_LOCKDOOR:
|
||||
case CDROM_DEBUG:
|
||||
break;
|
||||
default:
|
||||
/* unknown ioctl number */
|
||||
|
@ -699,8 +722,14 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
|
|||
struct backing_dev_info *bdi;
|
||||
loff_t size;
|
||||
|
||||
/*
|
||||
* O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have
|
||||
* to updated it before every ioctl.
|
||||
*/
|
||||
if (file->f_flags & O_NDELAY)
|
||||
mode |= FMODE_NDELAY_NOW;
|
||||
mode |= FMODE_NDELAY;
|
||||
else
|
||||
mode &= ~FMODE_NDELAY;
|
||||
|
||||
switch (cmd) {
|
||||
case HDIO_GETGEO:
|
||||
|
|
|
@ -2790,7 +2790,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
|
|||
return 0;
|
||||
|
||||
out_mem:
|
||||
blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
|
||||
blkdev_put(bdev, FMODE_READ | FMODE_NDELAY);
|
||||
/* This is safe: open() is still holding a reference. */
|
||||
module_put(THIS_MODULE);
|
||||
return ret;
|
||||
|
@ -2975,7 +2975,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
|
|||
pkt_debugfs_dev_remove(pd);
|
||||
pkt_sysfs_dev_remove(pd);
|
||||
|
||||
blkdev_put(pd->bdev, FMODE_READ|FMODE_WRITE);
|
||||
blkdev_put(pd->bdev, FMODE_READ | FMODE_NDELAY);
|
||||
|
||||
remove_proc_entry(pd->name, pkt_proc);
|
||||
DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name);
|
||||
|
|
|
@ -757,7 +757,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
|
|||
* access to the device is prohibited.
|
||||
*/
|
||||
error = scsi_nonblockable_ioctl(sdp, cmd, p,
|
||||
(mode & FMODE_NDELAY_NOW) != 0);
|
||||
(mode & FMODE_NDELAY) != 0);
|
||||
if (!scsi_block_when_processing_errors(sdp) || !error)
|
||||
return error;
|
||||
|
||||
|
|
|
@ -521,7 +521,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
|
|||
* if it doesn't recognise the ioctl
|
||||
*/
|
||||
ret = scsi_nonblockable_ioctl(sdev, cmd, argp,
|
||||
(mode & FMODE_NDELAY_NOW) != 0);
|
||||
(mode & FMODE_NDELAY) != 0);
|
||||
if (ret != -ENODEV)
|
||||
return ret;
|
||||
return scsi_ioctl(sdev, cmd, argp);
|
||||
|
|
|
@ -1135,12 +1135,15 @@ static int blkdev_open(struct inode * inode, struct file * filp)
|
|||
if (res)
|
||||
return res;
|
||||
|
||||
if (!(filp->f_mode & FMODE_EXCL))
|
||||
return 0;
|
||||
if (filp->f_mode & FMODE_EXCL) {
|
||||
res = bd_claim(bdev, filp);
|
||||
if (res)
|
||||
goto out_blkdev_put;
|
||||
}
|
||||
|
||||
if (!(res = bd_claim(bdev, filp)))
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
out_blkdev_put:
|
||||
blkdev_put(bdev, filp->f_mode);
|
||||
return res;
|
||||
}
|
||||
|
@ -1203,8 +1206,16 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
|
|||
{
|
||||
struct block_device *bdev = I_BDEV(file->f_mapping->host);
|
||||
fmode_t mode = file->f_mode;
|
||||
|
||||
/*
|
||||
* O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have
|
||||
* to updated it before every ioctl.
|
||||
*/
|
||||
if (file->f_flags & O_NDELAY)
|
||||
mode |= FMODE_NDELAY_NOW;
|
||||
mode |= FMODE_NDELAY;
|
||||
else
|
||||
mode &= ~FMODE_NDELAY;
|
||||
|
||||
return blkdev_ioctl(bdev, mode, cmd, arg);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,23 +63,24 @@ extern int dir_notify_enable;
|
|||
#define MAY_ACCESS 16
|
||||
#define MAY_OPEN 32
|
||||
|
||||
#define FMODE_READ ((__force fmode_t)1)
|
||||
#define FMODE_WRITE ((__force fmode_t)2)
|
||||
|
||||
/* Internal kernel extensions */
|
||||
#define FMODE_LSEEK ((__force fmode_t)4)
|
||||
#define FMODE_PREAD ((__force fmode_t)8)
|
||||
#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
|
||||
|
||||
/* File is being opened for execution. Primary users of this flag are
|
||||
distributed filesystems that can use it to achieve correct ETXTBUSY
|
||||
behavior for cross-node execution/opening_for_writing of files */
|
||||
#define FMODE_EXEC ((__force fmode_t)16)
|
||||
|
||||
#define FMODE_NDELAY ((__force fmode_t)32)
|
||||
#define FMODE_EXCL ((__force fmode_t)64)
|
||||
/* file is open for reading */
|
||||
#define FMODE_READ ((__force fmode_t)1)
|
||||
/* file is open for writing */
|
||||
#define FMODE_WRITE ((__force fmode_t)2)
|
||||
/* file is seekable */
|
||||
#define FMODE_LSEEK ((__force fmode_t)4)
|
||||
/* file can be accessed using pread/pwrite */
|
||||
#define FMODE_PREAD ((__force fmode_t)8)
|
||||
#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
|
||||
/* File is opened for execution with sys_execve / sys_uselib */
|
||||
#define FMODE_EXEC ((__force fmode_t)16)
|
||||
/* File is opened with O_NDELAY (only set for block devices) */
|
||||
#define FMODE_NDELAY ((__force fmode_t)32)
|
||||
/* File is opened with O_EXCL (only set for block devices) */
|
||||
#define FMODE_EXCL ((__force fmode_t)64)
|
||||
/* File is opened using open(.., 3, ..) and is writeable only for ioctls
|
||||
(specialy hack for floppy.c) */
|
||||
#define FMODE_WRITE_IOCTL ((__force fmode_t)128)
|
||||
#define FMODE_NDELAY_NOW ((__force fmode_t)256)
|
||||
|
||||
#define RW_MASK 1
|
||||
#define RWA_MASK 2
|
||||
|
|
|
@ -633,7 +633,7 @@ void swsusp_close(fmode_t mode)
|
|||
return;
|
||||
}
|
||||
|
||||
blkdev_put(resume_bdev, mode); /* move up */
|
||||
blkdev_put(resume_bdev, mode);
|
||||
}
|
||||
|
||||
static int swsusp_header_init(void)
|
||||
|
|
Loading…
Reference in a new issue