Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/geom_dev.c
Show First 20 Lines • Show All 628 Lines • ▼ Show 20 Lines | case DIOCGDELETE: | ||||
length = ((off_t *)data)[1]; | length = ((off_t *)data)[1]; | ||||
if ((offset % pp->sectorsize) != 0 || | if ((offset % pp->sectorsize) != 0 || | ||||
(length % pp->sectorsize) != 0 || length <= 0) { | (length % pp->sectorsize) != 0 || length <= 0) { | ||||
printf("%s: offset=%jd length=%jd\n", __func__, offset, | printf("%s: offset=%jd length=%jd\n", __func__, offset, | ||||
length); | length); | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
if ((pp->mediasize > 0) && (offset >= pp->mediasize)) { | |||||
/* | |||||
* Catch out-of-bounds requests here. The problem is | |||||
* that due to historical GEOM I/O implementation | |||||
* peculatities, g_delete_data() would always return | |||||
* success for requests starting just the next byte | |||||
* after providers media boundary. Condition check on | |||||
* non-zero media size, since that condition would | |||||
* (most likely) cause ENXIO instead. | |||||
*/ | |||||
error = EIO; | |||||
break; | |||||
} | |||||
while (length > 0) { | while (length > 0) { | ||||
chunk = length; | chunk = length; | ||||
if (g_dev_del_max_sectors != 0 && | if (g_dev_del_max_sectors != 0 && | ||||
chunk > g_dev_del_max_sectors * pp->sectorsize) { | chunk > g_dev_del_max_sectors * pp->sectorsize) { | ||||
chunk = g_dev_del_max_sectors * pp->sectorsize; | chunk = g_dev_del_max_sectors * pp->sectorsize; | ||||
if (pp->stripesize > 0) { | if (pp->stripesize > 0) { | ||||
odd = (offset + chunk + | odd = (offset + chunk + | ||||
pp->stripeoffset) % pp->stripesize; | pp->stripeoffset) % pp->stripesize; | ||||
▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines |