scst_vdisk: Fix 32-bit build

Avoid 64-bit modulo computations since these result in undefined symbol
errors on 32-bit systems (__moddi3 / __umoddi3). Support sizes >= 2**32
bytes on 32-bit systems.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5629 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2014-06-28 19:58:44 +00:00
parent bebce1c99f
commit 035e879dd6

View File

@@ -6086,7 +6086,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev,
char *params, const char *const allowed_params[])
{
int res = 0;
unsigned long val;
unsigned long long val;
char *param, *p, *pp;
TRACE_ENTRY();
@@ -6164,9 +6164,9 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev,
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
res = kstrtoul(pp, 0, &val);
res = kstrtoull(pp, 0, &val);
#else
res = strict_strtoul(pp, 0, &val);
res = strict_strtoull(pp, 0, &val);
#endif
if (res != 0) {
PRINT_ERROR("strtoul() for %s failed: %d (device %s)",
@@ -6208,7 +6208,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev,
} else if (!strcasecmp("tst", p)) {
if ((val != SCST_TST_0_SINGLE_TASK_SET) &&
(val != SCST_TST_1_SEP_TASK_SETS)) {
PRINT_ERROR("Invalid TST value %d", (int)val);
PRINT_ERROR("Invalid TST value %lld", val);
res = -EINVAL;
goto out;
}
@@ -6231,7 +6231,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev,
res = -EINVAL;
goto out;
}
TRACE_DBG("block size %ld, block shift %d",
TRACE_DBG("block size %lld, block shift %d",
val, virt_dev->blk_shift);
} else {
PRINT_ERROR("Unknown parameter %s (device %s)", p,
@@ -6241,7 +6241,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev,
}
}
if (virt_dev->file_size % (1 << virt_dev->blk_shift) != 0) {
if ((virt_dev->file_size & ((1 << virt_dev->blk_shift) - 1)) != 0) {
PRINT_ERROR("Device size %lld is not a multiple of the block"
" size %d", virt_dev->file_size,
1 << virt_dev->blk_shift);
@@ -6836,7 +6836,7 @@ static int vdev_size_process_store(struct scst_sysfs_work_item *work)
int size_shift, res = -EINVAL;
if (sscanf(work->buf, "%d %lld", &size_shift, &new_size) != 2 ||
new_size > (ULONG_MAX >> size_shift))
new_size > (ULLONG_MAX >> size_shift))
goto put;
new_size <<= size_shift;
@@ -6854,7 +6854,7 @@ static int vdev_size_process_store(struct scst_sysfs_work_item *work)
if (!virt_dev->nullio) {
res = -EPERM;
sBUG();
} else if (new_size % (1 << virt_dev->blk_shift) == 0) {
} else if ((new_size & ((1 << virt_dev->blk_shift) - 1)) == 0) {
virt_dev->file_size = new_size;
virt_dev->nblocks = virt_dev->file_size >> dev->block_shift;
} else {