提交 00ee65d9 编写于 作者: 张文迪

delete abandoned code and modify code style

Signed-off-by: N张文迪 <zhangwendi3@huawei.com>
上级 a6068434
......@@ -226,7 +226,6 @@ static const u_int8_t bootcode[] = {
static volatile sig_atomic_t got_siginfo;
static void infohandler(int);
static int check_mounted(const char *, mode_t);
static ssize_t getchunksize(void);
static int getstdfmt(const char *, struct bpb *);
static int getdiskinfo(int, const char *, const char *, int, struct bpb *);
......@@ -307,11 +306,6 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
warnx("warning, %s is not a character device", fname);
#endif
}
#ifndef MAKEFS
if (!o.no_create)
if (check_mounted(fname, sb.st_mode) == -1)
goto done;
#endif
if (o.offset && o.offset != lseek(fd, o.offset, SEEK_SET)) {
warnx("cannot seek to %jd", (intmax_t)o.offset);
goto done;
......@@ -801,45 +795,6 @@ done:
return rv;
}
/*
* return -1 with error if file system is mounted.
*/
static int
check_mounted(const char *fname, mode_t mode)
{
/*
* If getmntinfo() is not available (e.g. Linux) don't check. This should
* not be a problem since we will only be using makefs to create images.
*/
#if 0 && !defined(MAKEFS)
struct statfs *mp;
const char *s1, *s2;
size_t len;
int n, r;
if (!(n = getmntinfo(&mp, MNT_NOWAIT))) {
warn("getmntinfo");
return -1;
}
len = strlen(_PATH_DEV);
s1 = fname;
if (!strncmp(s1, _PATH_DEV, len))
s1 += len;
r = S_ISCHR(mode) && s1 != fname && *s1 == 'r';
for (; n--; mp++) {
s2 = mp->f_mntfromname;
if (!strncmp(s2, _PATH_DEV, len))
s2 += len;
if ((r && s2 != mp->f_mntfromname && !strcmp(s1 + 1, s2)) ||
!strcmp(s1, s2)) {
warnx("%s is mounted on %s", fname, mp->f_mntonname);
return -1;
}
}
#endif
return 0;
}
/*
* Get optimal I/O size
*/
......@@ -899,40 +854,22 @@ getstdfmt(const char *fmt, struct bpb *bpb)
return 0;
}
#if 0
static void
compute_geometry_from_file(int fd, const char *fname, struct disklabel *lp)
{
struct stat st;
off_t ms;
if (fstat(fd, &st))
err(1, "cannot get disk size");
if (!S_ISREG(st.st_mode))
errx(1, "%s is not a regular file", fname);
ms = st.st_size;
lp->d_secsize = 512;
lp->d_nsectors = 63;
lp->d_ntracks = 255;
lp->d_secperunit = ms / lp->d_secsize;
}
#endif
/*
* Get disk slice, partition, and geometry information.
*/
#if defined(__linux__)
static int getdiskinfo(int fd, const char *fname, const char *dtype,
int oflag, struct bpb *bpb)
static int
getdiskinfo(int fd, const char *fname, const char *dtype, int oflag,
struct bpb *bpb)
{
if (ioctl(fd, BLKSSZGET, &bpb->bpbBytesPerSec)) {
if (ioctl(fd, BLKSSZGET, &bpb->bpbBytesPerSec) == -1) {
err(1, "ioctl(BLKSSZGET) for bytes/sector failed");
}
if (ckgeom(fname, bpb->bpbBytesPerSec, "bytes/sector") == -1) return -1;
u_int64_t device_size;
if (ioctl(fd, BLKGETSIZE64, &device_size)) {
if (ioctl(fd, BLKGETSIZE64, &device_size) == -1) {
err(1, "ioctl(BLKGETSIZE64) failed");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册