コード例 #1
0
ファイル: wrapper.c プロジェクト: Niisp/MT6795.kernel
static int hfsplus_get_last_session(struct super_block *sb,
                                    sector_t *start, sector_t *size)
{
    struct cdrom_multisession ms_info;
    struct cdrom_tocentry te;
    int res;

    /* default values */
    *start = 0;
    *size = sb->s_bdev->bd_inode->i_size >> 9;

    if (HFSPLUS_SB(sb)->session >= 0) {
        te.cdte_track = HFSPLUS_SB(sb)->session;
        te.cdte_format = CDROM_LBA;
        res = ioctl_by_bdev(sb->s_bdev,
                            CDROMREADTOCENTRY, (unsigned long)&te);
        if (!res && (te.cdte_ctrl & CDROM_DATA_TRACK) == 4) {
            *start = (sector_t)te.cdte_addr.lba << 2;
            return 0;
        }
        pr_err("invalid session number or type of track\n");
        return -EINVAL;
    }
    ms_info.addr_format = CDROM_LBA;
    res = ioctl_by_bdev(sb->s_bdev, CDROMMULTISESSION,
                        (unsigned long)&ms_info);
    if (!res && ms_info.xa_flag)
        *start = (sector_t)ms_info.addr.lba << 2;
    return 0;
}
コード例 #2
0
/*
 * Trigger a partition detection.
 */
int dasd_scan_partitions(struct dasd_block *block)
{
	struct block_device *bdev;

	bdev = bdget_disk(block->gdp, 0);
	if (!bdev || blkdev_get(bdev, FMODE_READ) < 0)
		return -ENODEV;
	/*
	 * See fs/partition/check.c:register_disk,rescan_partitions
	 * Can't call rescan_partitions directly. Use ioctl.
	 */
	ioctl_by_bdev(bdev, BLKRRPART, 0);
	/*
	 * Since the matching blkdev_put call to the blkdev_get in
	 * this function is not called before dasd_destroy_partitions
	 * the offline open_count limit needs to be increased from
	 * 0 to 1. This is done by setting device->bdev (see
	 * dasd_generic_set_offline). As long as the partition
	 * detection is running no offline should be allowed. That
	 * is why the assignment to device->bdev is done AFTER
	 * the BLKRRPART ioctl.
	 */
	block->bdev = bdev;
	return 0;
}
コード例 #3
0
ファイル: lowlevel.c プロジェクト: 3sOx/asuswrt-merlin
unsigned int 
udf_get_last_session(struct super_block *sb)
{
	struct cdrom_multisession ms_info;
	unsigned int vol_desc_start;
	struct block_device *bdev = sb->s_bdev;
	int i;

	vol_desc_start=0;
	ms_info.addr_format=CDROM_LBA;
	i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);

#define WE_OBEY_THE_WRITTEN_STANDARDS 1

	if (i == 0)
	{
		udf_debug("XA disk: %s, vol_desc_start=%d\n",
			(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
#if WE_OBEY_THE_WRITTEN_STANDARDS
		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
#endif
			vol_desc_start = ms_info.addr.lba;
	}
	else
	{
		udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
	}
	return vol_desc_start;
}
コード例 #4
0
/*
 * Remove all inodes in the system for a device, delete the
 * partitions and make device unusable by setting its size to zero.
 */
void dasd_destroy_partitions(struct dasd_block *block)
{
	/* The two structs have 168/176 byte on 31/64 bit. */
	struct blkpg_partition bpart;
	struct blkpg_ioctl_arg barg;
	struct block_device *bdev;

	/*
	 * Get the bdev pointer from the device structure and clear
	 * device->bdev to lower the offline open_count limit again.
	 */
	bdev = block->bdev;
	block->bdev = NULL;

	/*
	 * See fs/partition/check.c:delete_partition
	 * Can't call delete_partitions directly. Use ioctl.
	 * The ioctl also does locking and invalidation.
	 */
	memset(&bpart, 0, sizeof(struct blkpg_partition));
	memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
	barg.data = (void __force __user *) &bpart;
	barg.op = BLKPG_DEL_PARTITION;
	for (bpart.pno = block->gdp->minors - 1; bpart.pno > 0; bpart.pno--)
		ioctl_by_bdev(bdev, BLKPG, (unsigned long) &barg);

	invalidate_partition(block->gdp, 0);
	/* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */
	blkdev_put(bdev, FMODE_READ);
	set_capacity(block->gdp, 0);
}
コード例 #5
0
ファイル: raw.c プロジェクト: sarnobat/knoppix
/*
 * Forward ioctls to the underlying block device.
 */
static int
raw_ioctl(struct inode *inode, struct file *filp,
		  unsigned int command, unsigned long arg)
{
	struct block_device *bdev = filp->private_data;

	return ioctl_by_bdev(bdev, command, arg);
}
コード例 #6
0
ファイル: lowlevel.c プロジェクト: iwangv/edimax-br-6528n
unsigned long
udf_get_last_block(struct super_block *sb)
{
	struct block_device *bdev = sb->s_bdev;
	int ret;
	unsigned long lblock = 0;

	ret = ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock);

	if (ret) /* Hard Disk */
	{
		ret = ioctl_by_bdev(bdev, BLKGETSIZE, (unsigned long) &lblock);

		if (!ret && lblock != 0x7FFFFFFF)
			lblock = ((512 * lblock) / sb->s_blocksize);
	}

	if (!ret && lblock)
		return lblock - 1;
	else
		return 0;
}
コード例 #7
0
ファイル: lowlevel.c プロジェクト: 3sOx/asuswrt-merlin
unsigned long
udf_get_last_block(struct super_block *sb)
{
	struct block_device *bdev = sb->s_bdev;
	unsigned long lblock = 0;

	if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
		lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;

	if (lblock)
		return lblock - 1;
	else
		return 0;
}
コード例 #8
0
unsigned int udf_get_last_session(struct super_block *sb)
{
	struct cdrom_multisession ms_info;
	unsigned int vol_desc_start;
	struct block_device *bdev = sb->s_bdev;
	int i;

	vol_desc_start = 0;
	ms_info.addr_format = CDROM_LBA;
	i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long)&ms_info);

	if (i == 0) {
		udf_debug("XA disk: %s, vol_desc_start=%d\n",
<<<<<<< HEAD
			  ms_info.xa_flag ? "yes" : "no", ms_info.addr.lba);
=======
<<<<<<< HEAD
コード例 #9
0
ファイル: lowlevel.c プロジェクト: flwh/Alcatel_OT_985_kernel
unsigned long udf_get_last_block(struct super_block *sb)
{
	struct block_device *bdev = sb->s_bdev;
	unsigned long lblock = 0;

	/*
	 * ioctl failed or returned obviously bogus value?
	 * Try using the device size...
	 */
	if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock) ||
	    lblock == 0)
		lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;

	if (lblock)
		return lblock - 1;
	else
		return 0;
}