summaryrefslogtreecommitdiffstats
path: root/lib/libstand
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /lib/libstand
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'lib/libstand')
-rw-r--r--lib/libstand/Makefile45
-rw-r--r--lib/libstand/cd9660.c15
-rw-r--r--lib/libstand/dosfs.c3
-rw-r--r--lib/libstand/ext2fs.c12
-rw-r--r--lib/libstand/libstand.32
-rw-r--r--lib/libstand/nandfs.c2
-rw-r--r--lib/libstand/nfs.c4
-rw-r--r--lib/libstand/powerpc/_setjmp.S4
-rw-r--r--lib/libstand/powerpc/syncicache.c103
-rw-r--r--lib/libstand/printf.c4
-rw-r--r--lib/libstand/read.c2
-rw-r--r--lib/libstand/stand.h3
-rw-r--r--lib/libstand/tftp.c4
-rw-r--r--lib/libstand/twiddle.c21
-rw-r--r--lib/libstand/ufs.c14
-rw-r--r--lib/libstand/write.c2
16 files changed, 185 insertions, 55 deletions
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index e57407f..2ee2921 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -11,6 +11,9 @@ MK_SSP= no
.include <src.opts.mk>
+LIBSTAND_SRC= ${.CURDIR}
+LIBC_SRC= ${LIBSTAND_SRC}/../libc
+
LIB= stand
NO_PIC=
INCS= stand.h
@@ -19,7 +22,7 @@ MAN= libstand.3
WARNS?= 0
CFLAGS+= -ffreestanding -Wformat
-CFLAGS+= -I${.CURDIR}
+CFLAGS+= -I${LIBSTAND_SRC}
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
@@ -28,7 +31,7 @@ CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
CFLAGS.gcc+= -mpreferred-stack-boundary=2
.endif
.if ${MACHINE_CPUARCH} == "amd64"
-CFLAGS+= -fPIC
+CFLAGS+= -fPIC -mno-red-zone
.endif
.if ${MACHINE} == "pc98"
CFLAGS+= -Os
@@ -39,6 +42,9 @@ CFLAGS+= -msoft-float -D_STANDALONE -DNETIF_DEBUG
.if ${MACHINE_CPUARCH} == "arm"
CFLAGS+= -msoft-float -D_STANDALONE
.endif
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+= -D_STANDALONE -mgeneral-regs-only
+.endif
.if ${MACHINE_CPUARCH} == "mips"
CFLAGS+= -G0 -fno-pic -mno-abicalls
.endif
@@ -51,55 +57,54 @@ SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c g
# private (pruned) versions of libc string functions
SRCS+= strcasecmp.c
-.PATH: ${.CURDIR}/../libc/net
+.PATH: ${LIBC_SRC}/net
SRCS+= ntoh.c
# string functions from libc
-.PATH: ${.CURDIR}/../libc/string
+.PATH: ${LIBC_SRC}/string
SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
.if ${MACHINE_CPUARCH} == "arm"
-.PATH: ${.CURDIR}/../libc/arm/gen
+.PATH: ${LIBC_SRC}/arm/gen
# Compiler support functions
-.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/
+.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
# __clzsi2 and ctzsi2 for various builtin functions
SRCS+= clzsi2.c ctzsi2.c
# Divide and modulus functions called by the compiler
SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c
SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
-.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/arm/
+.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
+.endif
+.if ${MACHINE_CPUARCH} == "aarch64"
+.PATH: ${LIBC_SRC}/aarch64/gen
.endif
+
.if ${MACHINE_CPUARCH} == "powerpc"
-.PATH: ${.CURDIR}/../libc/quad
+.PATH: ${LIBC_SRC}/quad
SRCS+= ashldi3.c ashrdi3.c
-.PATH: ${.CURDIR}/../libc/powerpc/gen
SRCS+= syncicache.c
.endif
# uuid functions from libc
-.PATH: ${.CURDIR}/../libc/uuid
+.PATH: ${LIBC_SRC}/uuid
SRCS+= uuid_equal.c uuid_is_nil.c
# _setjmp/_longjmp
-.if ${MACHINE_ARCH} == "powerpc64"
-.PATH: ${.CURDIR}/powerpc
-.else
-.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
-.endif
+.PATH: ${LIBSTAND_SRC}/${MACHINE_CPUARCH}
SRCS+= _setjmp.S
# decompression functionality from libbz2
# NOTE: to actually test this functionality after libbz2 upgrade compile
# loader(8) with LOADER_BZIP2_SUPPORT defined
-.PATH: ${.CURDIR}/../../contrib/bzip2
+.PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
SRCS+= libstand_bzlib_private.h
@@ -108,7 +113,8 @@ SRCS+= _${file}
CLEANFILES+= _${file}
_${file}: ${file}
- sed "s|bzlib_private\.h|libstand_bzlib_private.h|" ${.ALLSRC} > ${.TARGET}
+ sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
+ ${.ALLSRC} > ${.TARGET}
.endfor
CLEANFILES+= libstand_bzlib_private.h
@@ -117,8 +123,8 @@ libstand_bzlib_private.h: bzlib_private.h
${.ALLSRC} > ${.TARGET}
# decompression functionality from libz
-.PATH: ${.CURDIR}/../libz
-CFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../libz
+.PATH: ${LIBSTAND_SRC}/../libz
+CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz
SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
@@ -163,4 +169,3 @@ SRCS+= nandfs.c
.endif
.include <bsd.lib.mk>
-
diff --git a/lib/libstand/cd9660.c b/lib/libstand/cd9660.c
index c6bcef2..09cc7f8 100644
--- a/lib/libstand/cd9660.c
+++ b/lib/libstand/cd9660.c
@@ -151,9 +151,14 @@ susp_lookup_record(struct open_file *f, const char *identifier,
return (NULL);
p = susp_buffer + isonum_733(shc->offset);
end = p + isonum_733(shc->length);
- } else
+ } else {
/* Ignore this record and skip to the next. */
p += isonum_711(sh->length);
+
+ /* Avoid infinite loops with corrupted file systems */
+ if (isonum_711(sh->length) == 0)
+ return (NULL);
+ }
}
return (NULL);
}
@@ -281,7 +286,7 @@ cd9660_open(const char *path, struct open_file *f)
buf = malloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
vd = buf;
for (bno = 16;; bno++) {
- twiddle();
+ twiddle(1);
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
ISO_DEFAULT_BLOCK_SIZE, buf, &read);
if (rc)
@@ -314,7 +319,7 @@ cd9660_open(const char *path, struct open_file *f)
while (off < dsize) {
if ((off % ISO_DEFAULT_BLOCK_SIZE) == 0) {
- twiddle();
+ twiddle(1);
rc = f->f_dev->dv_strategy
(f->f_devdata, F_READ,
cdb2devb(bno + boff),
@@ -374,7 +379,7 @@ cd9660_open(const char *path, struct open_file *f)
/* Check for Rock Ridge since we didn't in the loop above. */
bno = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length);
- twiddle();
+ twiddle(1);
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
ISO_DEFAULT_BLOCK_SIZE, buf, &read);
if (rc)
@@ -431,7 +436,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
if (fp->f_buf == (char *)0)
fp->f_buf = malloc(ISO_DEFAULT_BLOCK_SIZE);
- twiddle();
+ twiddle(16);
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ,
cdb2devb(blkno), ISO_DEFAULT_BLOCK_SIZE, fp->f_buf, &read);
if (rc)
diff --git a/lib/libstand/dosfs.c b/lib/libstand/dosfs.c
index 72205a2..b75d752 100644
--- a/lib/libstand/dosfs.c
+++ b/lib/libstand/dosfs.c
@@ -786,7 +786,8 @@ static int
ioget(struct open_file *fd, u_int lsec, void *buf, u_int nsec)
{
int err;
-
+
+ twiddle(1);
if ((err = (fd->f_dev->dv_strategy)(fd->f_devdata, F_READ, lsec,
secbyt(nsec), buf, NULL)))
return(err);
diff --git a/lib/libstand/ext2fs.c b/lib/libstand/ext2fs.c
index e0afb3e..d0b91e0 100644
--- a/lib/libstand/ext2fs.c
+++ b/lib/libstand/ext2fs.c
@@ -353,7 +353,7 @@ ext2fs_open(const char *upath, struct open_file *f)
/* allocate space and read super block */
fs = (struct ext2fs *)malloc(sizeof(*fs));
fp->f_fs = fs;
- twiddle();
+ twiddle(1);
error = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
EXT2_SBLOCK, EXT2_SBSIZE, (char *)fs, &buf_size);
if (error)
@@ -395,7 +395,7 @@ ext2fs_open(const char *upath, struct open_file *f)
len = blkgrps * fs->fs_bsize;
fp->f_bg = malloc(len);
- twiddle();
+ twiddle(1);
error = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
EXT2_SBLOCK + EXT2_SBSIZE / DEV_BSIZE, len,
(char *)fp->f_bg, &buf_size);
@@ -507,7 +507,7 @@ ext2fs_open(const char *upath, struct open_file *f)
if (error)
goto out;
- twiddle();
+ twiddle(1);
error = (f->f_dev->dv_strategy)(f->f_devdata,
F_READ, fsb_to_db(fs, disk_block),
fs->fs_bsize, buf, &buf_size);
@@ -568,7 +568,7 @@ read_inode(ino_t inumber, struct open_file *f)
* Read inode and save it.
*/
buf = malloc(fs->fs_bsize);
- twiddle();
+ twiddle(1);
error = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
ino_to_db(fs, fp->f_bg, inumber), fs->fs_bsize, buf, &rsize);
if (error)
@@ -665,7 +665,7 @@ block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
if (fp->f_blk[level] == (char *)0)
fp->f_blk[level] =
malloc(fs->fs_bsize);
- twiddle();
+ twiddle(1);
error = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsb_to_db(fp->f_fs, ind_block_num), fs->fs_bsize,
fp->f_blk[level], &fp->f_blksize[level]);
@@ -723,7 +723,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
bzero(fp->f_buf, block_size);
fp->f_buf_size = block_size;
} else {
- twiddle();
+ twiddle(4);
error = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsb_to_db(fs, disk_block), block_size,
fp->f_buf, &fp->f_buf_size);
diff --git a/lib/libstand/libstand.3 b/lib/libstand/libstand.3
index b42c8b5..42289c1 100644
--- a/lib/libstand/libstand.3
+++ b/lib/libstand/libstand.3
@@ -288,7 +288,7 @@ Thus
printf(
.Qq reg=%b\en ,
3,
-.Qq \e10\e2BITTWO\e1BITONE\en
+.Qq \e10\e2BITTWO\e1BITONE
);
.Ed
.Pp
diff --git a/lib/libstand/nandfs.c b/lib/libstand/nandfs.c
index 713dc12..b8c51e3 100644
--- a/lib/libstand/nandfs.c
+++ b/lib/libstand/nandfs.c
@@ -921,7 +921,7 @@ nandfs_bmap_lookup(struct nandfs *fs, struct nandfs_node *node,
return (0);
}
- twiddle();
+ twiddle(1);
NANDFS_DEBUG("calling get_map with %jx\n", ind_block_num);
map = nandfs_get_map(fs, node, ind_block_num, phys);
if (map == NULL)
diff --git a/lib/libstand/nfs.c b/lib/libstand/nfs.c
index adb0a11..a0b726c 100644
--- a/lib/libstand/nfs.c
+++ b/lib/libstand/nfs.c
@@ -662,7 +662,7 @@ nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
(int)fp->off);
#endif
while ((int)size > 0) {
- twiddle();
+ twiddle(16);
cc = nfs_readdata(fp, fp->off, (void *)addr, size);
/* XXX maybe should retry on certain errors */
if (cc == -1) {
@@ -1311,7 +1311,7 @@ nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
(int)fp->off);
#endif
while ((int)size > 0) {
- twiddle();
+ twiddle(16);
cc = nfs_readdata(fp, fp->off, (void *)addr, size);
/* XXX maybe should retry on certain errors */
if (cc == -1) {
diff --git a/lib/libstand/powerpc/_setjmp.S b/lib/libstand/powerpc/_setjmp.S
index 3884b11..7c7c24b 100644
--- a/lib/libstand/powerpc/_setjmp.S
+++ b/lib/libstand/powerpc/_setjmp.S
@@ -42,7 +42,7 @@
#define JMP_xer 24*REGWIDTH
#define JMP_sig 25*REGWIDTH
-ASENTRY_NOPROF(setjmp)
+ASENTRY_NOPROF(_setjmp)
ST_REG 31, JMP_r31(3)
/* r1, r2, r14-r30 */
ST_REG 1, JMP_r1 (3)
@@ -79,7 +79,7 @@ ASENTRY_NOPROF(setjmp)
.extern sigsetmask
-ASENTRY_NOPROF(longjmp)
+ASENTRY_NOPROF(_longjmp)
LD_REG 31, JMP_r31(3)
/* r1, r2, r14-r30 */
LD_REG 1, JMP_r1 (3)
diff --git a/lib/libstand/powerpc/syncicache.c b/lib/libstand/powerpc/syncicache.c
new file mode 100644
index 0000000..434dcec
--- /dev/null
+++ b/lib/libstand/powerpc/syncicache.c
@@ -0,0 +1,103 @@
+/*-
+ * Copyright (C) 1995-1997, 1999 Wolfgang Solfrank.
+ * Copyright (C) 1995-1997, 1999 TooLs GmbH.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $NetBSD: syncicache.c,v 1.2 1999/05/05 12:36:40 tsubai Exp $
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <sys/param.h>
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/time.h>
+#include <sys/proc.h>
+#include <vm/vm.h>
+#endif
+#include <sys/sysctl.h>
+
+#include <machine/cpu.h>
+#include <machine/md_var.h>
+
+#ifdef _STANDALONE
+int cacheline_size = 32;
+#endif
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <stdlib.h>
+
+int cacheline_size = 0;
+
+static void getcachelinesize(void);
+
+static void
+getcachelinesize()
+{
+ static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE };
+ int clen;
+
+ clen = sizeof(cacheline_size);
+
+ if (sysctl(cachemib, sizeof(cachemib) / sizeof(cachemib[0]),
+ &cacheline_size, &clen, NULL, 0) < 0 || !cacheline_size) {
+ abort();
+ }
+}
+#endif
+
+void
+__syncicache(void *from, int len)
+{
+ int l, off;
+ char *p;
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+ if (!cacheline_size)
+ getcachelinesize();
+#endif
+
+ off = (u_int)from & (cacheline_size - 1);
+ l = len += off;
+ p = (char *)from - off;
+
+ do {
+ __asm __volatile ("dcbst 0,%0" :: "r"(p));
+ p += cacheline_size;
+ } while ((l -= cacheline_size) > 0);
+ __asm __volatile ("sync");
+ p = (char *)from - off;
+ do {
+ __asm __volatile ("icbi 0,%0" :: "r"(p));
+ p += cacheline_size;
+ } while ((len -= cacheline_size) > 0);
+ __asm __volatile ("sync; isync");
+}
+
diff --git a/lib/libstand/printf.c b/lib/libstand/printf.c
index 157b327..fef5341 100644
--- a/lib/libstand/printf.c
+++ b/lib/libstand/printf.c
@@ -187,7 +187,7 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
* the next characters (up to a control character, i.e. a character <= 32),
* give the name of the register. Thus:
*
- * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
+ * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE");
*
* would produce output:
*
@@ -500,7 +500,7 @@ number:
while (percent < fmt)
PCHAR(*percent++);
/*
- * Since we ignore an formatting argument it is no
+ * Since we ignore a formatting argument it is no
* longer safe to obey the remaining formatting
* arguments as the arguments will no longer match
* the format specs.
diff --git a/lib/libstand/read.c b/lib/libstand/read.c
index 4c67dbe..a984dbe 100644
--- a/lib/libstand/read.c
+++ b/lib/libstand/read.c
@@ -77,7 +77,7 @@ read(int fd, void *dest, size_t bcount)
return (-1);
}
if (f->f_flags & F_RAW) {
- twiddle();
+ twiddle(4);
errno = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
btodb(f->f_offset), bcount, dest, &resid);
if (errno)
diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h
index bcd146a..22ee319 100644
--- a/lib/libstand/stand.h
+++ b/lib/libstand/stand.h
@@ -242,7 +242,8 @@ extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3);
extern int snprintf(char *buf, size_t size, const char *cfmt, ...) __printflike(3, 4);
extern void vsprintf(char *buf, const char *cfmt, __va_list);
-extern void twiddle(void);
+extern void twiddle(u_int callerdiv);
+extern void twiddle_divisor(u_int globaldiv);
extern void ngets(char *, int);
#define gets(x) ngets((x), 0)
diff --git a/lib/libstand/tftp.c b/lib/libstand/tftp.c
index e3983c3..6527c4e 100644
--- a/lib/libstand/tftp.c
+++ b/lib/libstand/tftp.c
@@ -447,14 +447,12 @@ tftp_read(struct open_file *f, void *addr, size_t size,
size_t *resid /* out */)
{
struct tftp_handle *tftpfile;
- static int tc = 0;
tftpfile = (struct tftp_handle *) f->f_fsdata;
while (size > 0) {
int needblock, count;
- if (!(tc++ % 16))
- twiddle();
+ twiddle(32);
needblock = tftpfile->off / tftpfile->tftp_blksize + 1;
diff --git a/lib/libstand/twiddle.c b/lib/libstand/twiddle.c
index e0a4c08..96ebbbe 100644
--- a/lib/libstand/twiddle.c
+++ b/lib/libstand/twiddle.c
@@ -42,11 +42,28 @@ __FBSDID("$FreeBSD$");
/* Extra functions from NetBSD standalone printf.c */
+static u_int globaldiv;
+
void
-twiddle()
+twiddle(u_int callerdiv)
{
- static int pos;
+ static u_int callercnt, globalcnt, pos;
+
+ callercnt++;
+ if (callerdiv > 1 && (callercnt % callerdiv) != 0)
+ return;
+
+ globalcnt++;
+ if (globaldiv > 1 && (globalcnt % globaldiv) != 0)
+ return;
putchar("|/-\\"[pos++ & 3]);
putchar('\b');
}
+
+void
+twiddle_divisor(u_int gdiv)
+{
+
+ globaldiv = gdiv;
+}
diff --git a/lib/libstand/ufs.c b/lib/libstand/ufs.c
index b6f7815..928a1d1 100644
--- a/lib/libstand/ufs.c
+++ b/lib/libstand/ufs.c
@@ -155,7 +155,7 @@ read_inode(inumber, f)
* Read inode and save it.
*/
buf = malloc(fs->fs_bsize);
- twiddle();
+ twiddle(1);
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize,
buf, &rsize);
@@ -265,7 +265,7 @@ block_map(f, file_block, disk_block_p)
if (fp->f_blk[level] == (char *)0)
fp->f_blk[level] =
malloc(fs->fs_bsize);
- twiddle();
+ twiddle(1);
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fp->f_fs, ind_block_num),
fs->fs_bsize,
@@ -346,7 +346,7 @@ buf_write_file(f, buf_p, size_p)
if (fp->f_buf == (char *)0)
fp->f_buf = malloc(fs->fs_bsize);
- twiddle();
+ twiddle(4);
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fs, disk_block),
block_size, fp->f_buf, &fp->f_buf_size);
@@ -365,7 +365,7 @@ buf_write_file(f, buf_p, size_p)
* Write the block out to storage.
*/
- twiddle();
+ twiddle(4);
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE,
fsbtodb(fs, disk_block),
block_size, fp->f_buf, &fp->f_buf_size);
@@ -406,7 +406,7 @@ buf_read_file(f, buf_p, size_p)
bzero(fp->f_buf, block_size);
fp->f_buf_size = block_size;
} else {
- twiddle();
+ twiddle(4);
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fs, disk_block),
block_size, fp->f_buf, &fp->f_buf_size);
@@ -515,7 +515,7 @@ ufs_open(upath, f)
/* allocate space and read super block */
fs = malloc(SBLOCKSIZE);
fp->f_fs = fs;
- twiddle();
+ twiddle(1);
/*
* Try reading the superblock in each of its possible locations.
*/
@@ -649,7 +649,7 @@ ufs_open(upath, f)
if (rc)
goto out;
- twiddle();
+ twiddle(1);
rc = (f->f_dev->dv_strategy)(f->f_devdata,
F_READ, fsbtodb(fs, disk_block),
fs->fs_bsize, buf, &buf_size);
diff --git a/lib/libstand/write.c b/lib/libstand/write.c
index dccdb8b..9e02f08 100644
--- a/lib/libstand/write.c
+++ b/lib/libstand/write.c
@@ -80,7 +80,7 @@ write(fd, dest, bcount)
return (-1);
}
if (f->f_flags & F_RAW) {
- twiddle();
+ twiddle(4);
errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE,
btodb(f->f_offset), bcount, dest, &resid);
if (errno)
OpenPOWER on IntegriCloud