netbsd fsck driver import
. fsck driver parses /etc/fstab and invokes sub-fscks . further simplifies fs handling in rc
This commit is contained in:
@@ -20,7 +20,7 @@ SUBDIR= csu ${LIBCOMPAT_DIR} ${LIBC_DIR} libblockdriver libchardriver \
|
||||
libnetdriver libedit ${LIBM_DIR} libsys libtimers ${LIBUTIL_DIR} \
|
||||
libl libhgfs libz libfetch libvtreefs libaudiodriver libmthread \
|
||||
libexec libdevman libusb ${LIBMINLIB_DIR} ${LIBASYN_DIR} \
|
||||
libddekit libminixfs libbdev
|
||||
libddekit libminixfs libbdev
|
||||
|
||||
.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no")
|
||||
SUBDIR+= libelf libminc libcrypt libterminfo libcurses libvassert libutil \
|
||||
|
||||
@@ -94,6 +94,7 @@ SRCS+= \
|
||||
setmode.c \
|
||||
settimeofday.c \
|
||||
shquote.c \
|
||||
sizeup.c \
|
||||
stderr.c \
|
||||
strcasestr.c \
|
||||
strdup.c \
|
||||
|
||||
52
lib/libc/other/sizeup.c
Normal file
52
lib/libc/other/sizeup.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include "namespace.h"
|
||||
#include <lib.h>
|
||||
#include <minix/u64.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <minix/config.h>
|
||||
#include <minix/const.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <minix/partition.h>
|
||||
#include <sys/ioc_disk.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/*================================================================
|
||||
* minix_sizeup - determine device size
|
||||
*===============================================================*/
|
||||
int minix_sizeup(device, bytes)
|
||||
char *device;
|
||||
u64_t *bytes;
|
||||
{
|
||||
int fd;
|
||||
struct partition entry;
|
||||
struct stat st;
|
||||
|
||||
if ((fd = open(device, O_RDONLY)) == -1) {
|
||||
if (errno != ENOENT)
|
||||
perror("sizeup open");
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DIOCGETP, &entry) == -1) {
|
||||
perror("sizeup ioctl");
|
||||
if(fstat(fd, &st) < 0) {
|
||||
perror("fstat");
|
||||
entry.size = cvu64(0);
|
||||
} else {
|
||||
entry.size = cvu64(st.st_size);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
*bytes = entry.size;
|
||||
return 0;
|
||||
}
|
||||
@@ -61,14 +61,17 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
rawpart = getrawpartition();
|
||||
if (rawpart < 0)
|
||||
return (-1); /* sysctl(3) in getrawpartition sets errno */
|
||||
#endif
|
||||
|
||||
f = ofn(buf, flags, 0);
|
||||
if (f != -1 || errno != ENOENT)
|
||||
return (f);
|
||||
|
||||
#ifndef __minix
|
||||
snprintf(buf, buflen, "%s%c", path, 'a' + rawpart);
|
||||
f = ofn(buf, flags, 0);
|
||||
if (f != -1 || errno != ENOENT)
|
||||
@@ -85,6 +88,7 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked,
|
||||
snprintf(buf, buflen, "%s%s%s%c", _PATH_DEV, iscooked ? "" : "r", path,
|
||||
'a' + rawpart);
|
||||
f = ofn(buf, flags, 0);
|
||||
#endif
|
||||
return (f);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ SRCS+= accept.c access.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \
|
||||
vectorio.c shutdown.c sigaction.c sigpending.c sigreturn.c sigsuspend.c\
|
||||
sigprocmask.c socket.c socketpair.c stat.c statvfs.c symlink.c \
|
||||
sync.c syscall.c sysuname.c truncate.c umask.c unlink.c write.c \
|
||||
_exit.c _ucontext.c environ.c __getcwd.c vfork.c
|
||||
_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c
|
||||
|
||||
# Minix specific syscalls.
|
||||
SRCS+= cprofile.c lseek64.c sprofile.c _mcontext.c
|
||||
|
||||
52
lib/nbsd_libc/sys-minix/sizeup.c
Normal file
52
lib/nbsd_libc/sys-minix/sizeup.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include "namespace.h"
|
||||
#include <lib.h>
|
||||
#include <minix/u64.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <minix/config.h>
|
||||
#include <minix/const.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <minix/partition.h>
|
||||
#include <sys/ioc_disk.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/*================================================================
|
||||
* minix_sizeup - determine device size
|
||||
*===============================================================*/
|
||||
int minix_sizeup(device, bytes)
|
||||
char *device;
|
||||
u64_t *bytes;
|
||||
{
|
||||
int fd;
|
||||
struct partition entry;
|
||||
struct stat st;
|
||||
|
||||
if ((fd = open(device, O_RDONLY)) == -1) {
|
||||
if (errno != ENOENT)
|
||||
perror("sizeup open");
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DIOCGETP, &entry) == -1) {
|
||||
perror("sizeup ioctl");
|
||||
if(fstat(fd, &st) < 0) {
|
||||
perror("fstat");
|
||||
entry.size = cvu64(0);
|
||||
} else {
|
||||
entry.size = cvu64(st.st_size);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
*bytes = entry.size;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user