Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: disklabel trouble
On Sat, Jul 16, 2011 at 09:26:18PM +0100, Patrick Welche wrote:
> 030 39 30 32 31 3a 5c 20 20 20 20 0a 3a 70 61 23 38
> 9021:\.....:pa#8
^^^^^^^^^^^^
So, it seems that trailing spaces after the \ at the end of a disktab line
completely confuse disklabel (or is it cgetnum()).
This is illustrated by creating a "disktab" file containing
test:\
:dt=ESDI:se#512:ns#63:nt#16:sc#1008:nc#969021:\
:pa#842022912:oa#107931648:ta=4.2BSD:ba#0:fa#0:\
:pc#842022912:oc#107931648:\
:pd#976773168:od#0:
and running the attached program:
% ./disktabtest test disktab
d_npartitions: 4
Now add eg 3 spaces at the end of the second line of "disktab", and repeat:
% ./disktabtest test disktab
d_npartitions: 0
That does't seem very robust... (now looking at cgetnum())
Cheers,
Patrick
PROG=disktabtest
CPPFLAGS+=-Wall
DBG=-g -O0
MKMAN=no
.include <bsd.prog.mk>
#include <sys/types.h>
#include <sys/disklabel.h>
#include <machine/int_fmtio.h>
#include <disktab.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
char defaultdisktab[] = _PATH_DISKTAB;
char *diskname, *disktab = defaultdisktab;
struct disklabel *dl;
switch (argc) {
case 3:
disktab = argv[2];
if (setdisktab(disktab) == -1)
err(1, "disktab file \"%s\" not valid", disktab);
case 2:
diskname = argv[1];
break;
default:
fprintf(stderr, "usage: %s diskname [disktab]\n", argv[0]);
exit(1);
}
dl = getdiskbyname(diskname);
if (dl == NULL)
err(1, "entry \"%s\" not found in disktab file \"%s\"",
diskname, disktab);
printf("d_npartitions: %"PRIu16"\n", dl->d_npartitions);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index