Allow either parameter to the getbsize(3) function to be a NULL, in
which case it is ignored.
This commit is contained in:
parent
afff857edc
commit
20a5af5edd
@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: getbsize.3,v 1.6 2003/04/16 13:34:36 wiz Exp $
|
.\" $NetBSD: getbsize.3,v 1.7 2003/05/30 00:12:09 simonb Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1993
|
.\" Copyright (c) 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
@ -33,7 +33,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93
|
.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93
|
||||||
.\"
|
.\"
|
||||||
.Dd June 4, 1993
|
.Dd May 10, 2003
|
||||||
.Dt GETBSIZE 3
|
.Dt GETBSIZE 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -56,14 +56,25 @@ for details on its use and format.
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Nm getbsize
|
.Nm getbsize
|
||||||
function returns a pointer to a null-terminated string describing
|
function returns a pointer to a
|
||||||
|
.Dv NUL
|
||||||
|
terminated string describing
|
||||||
the block size, something like
|
the block size, something like
|
||||||
.Dq 1K-blocks .
|
.Dq 1K-blocks .
|
||||||
The memory referenced by
|
If the
|
||||||
|
.Fa headerlenp
|
||||||
|
parameter is not
|
||||||
|
.Dv NULL
|
||||||
|
the memory referenced by
|
||||||
.Fa headerlenp
|
.Fa headerlenp
|
||||||
is filled in with the length of the string (not including the
|
is filled in with the length of the string (not including the
|
||||||
terminating null).
|
terminating
|
||||||
The memory referenced by
|
.Dv NUL ) .
|
||||||
|
If the
|
||||||
|
.Fa blocksizep
|
||||||
|
parameter is not
|
||||||
|
.Dv NULL
|
||||||
|
the memory referenced by
|
||||||
.Fa blocksizep
|
.Fa blocksizep
|
||||||
is filled in with block size, in bytes.
|
is filled in with block size, in bytes.
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: getbsize.c,v 1.13 2000/01/22 22:19:10 mycroft Exp $ */
|
/* $NetBSD: getbsize.c,v 1.14 2003/05/30 00:12:09 simonb Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: getbsize.c,v 1.13 2000/01/22 22:19:10 mycroft Exp $");
|
__RCSID("$NetBSD: getbsize.c,v 1.14 2003/05/30 00:12:09 simonb Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -63,9 +63,6 @@ getbsize(headerlenp, blocksizep)
|
|||||||
long n, max, mul, blocksize;
|
long n, max, mul, blocksize;
|
||||||
char *ep, *p, *form;
|
char *ep, *p, *form;
|
||||||
|
|
||||||
_DIAGASSERT(headerlenp != NULL);
|
|
||||||
_DIAGASSERT(blocksizep != NULL);
|
|
||||||
|
|
||||||
#define KB (1024L)
|
#define KB (1024L)
|
||||||
#define MB (1024L * 1024L)
|
#define MB (1024L * 1024L)
|
||||||
#define GB (1024L * 1024L * 1024L)
|
#define GB (1024L * 1024L * 1024L)
|
||||||
@ -117,7 +114,10 @@ underflow: warnx("%s: minimum blocksize is 512", p);
|
|||||||
} else
|
} else
|
||||||
blocksize = n = 512;
|
blocksize = n = 512;
|
||||||
|
|
||||||
*headerlenp = snprintf(header, sizeof(header), "%ld%s-blocks", n, form);
|
if (headerlenp)
|
||||||
*blocksizep = blocksize;
|
*headerlenp =
|
||||||
|
snprintf(header, sizeof(header), "%ld%s-blocks", n, form);
|
||||||
|
if (blocksizep)
|
||||||
|
*blocksizep = blocksize;
|
||||||
return (header);
|
return (header);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user