代码拉取完成,页面将自动刷新
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) 2010 Denys Vlasenko
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
#include "libbb.h"
uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
const char *override,
unsigned override_units,
int extend)
{
uoff_t result;
if (override) {
result = XATOOFF(override);
if (result >= (uoff_t)(MAXINT(off_t)) / override_units)
bb_simple_error_msg_and_die("image size is too big");
result *= override_units;
/* seek past end fails on block devices but works on files */
if (lseek(fd, result - 1, SEEK_SET) != (off_t)-1) {
if (extend)
xwrite(fd, "", 1); /* file grows if needed */
}
//else {
// bb_error_msg("warning, block device is smaller");
//}
} else {
/* more portable than BLKGETSIZE[64] */
result = xlseek(fd, 0, SEEK_END);
}
xlseek(fd, 0, SEEK_SET);
/* Prevent things like this:
* $ dd if=/dev/zero of=foo count=1 bs=1024
* $ mkswap foo
* Setting up swapspace version 1, size = 18446744073709548544 bytes
*
* Picked 16k arbitrarily: */
if (result < 16*1024)
bb_simple_error_msg_and_die("image is too small");
return result;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。