indent(1) has issues formatting lsblk(8) correctly

2023-09-01 Thread Benjamin Stürz

Hi misc@,

while trying to use indent(1) on my lsblk.c, I get the following two 
errors:> Error@150: Stmt nesting error.

Error@702: Missing braces at end of file.


It also doesn't handle unicode and breaks horribly at some points.

I have attached both the origin and the indented version
as Thunderbird doesn't seem to wanna deal with so much text.

For now, I'm just gonna do it myself according to style(9).

Thanks,
Benjamin Stürz
/*
 * Copyright (c) 2023 Benjamin StГјrz 
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
#define _XOPEN_SOURCE 700
#define _BSD_SOURCE 1
#define DKTYPENAMES
#define WSDEBUG 0
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

static int 
diskcount(void)
{
	const int 	mib  [2] = {CTL_HW, HW_DISKCOUNT};
	int 		diskcount;
	size_t 		len = sizeof diskcount;

	if (sysctl(mib, 2, &diskcount, &len, NULL, 0) == -1)
		err(1, "sysctl(hw.diskcount)");

	return diskcount;
}

static char*
disknames(void)
{
	const int 	num = diskcount();
	const int 	mib  [2] = {CTL_HW, HW_DISKNAMES};
	size_t 		len = 32 * num;
	char   *buffer = malloc(len);

	if (sysctl(mib, 2, buffer, &len, NULL, 0) == -1)
		err(1, "sysctl(hw.disknames)");

	return buffer;
}

static char*
stripdisk(char *n)
{
	const char 	sufx[] = " disk";
	const size_t 	ln = strnlen(n, 16);
	const size_t 	ls = sizeof sufx - 1;

	if (memcmp(n + ln - ls, sufx, ls) == 0) {
		n[ln - ls] = '\0';
	}
	return n;
}

static void 
print_size(uint64_t sz)
{
	const struct unit {
		char 		sym;
		uint64_t 	factor;
	} 		units   [] = {
		{
			'P', 1ull << 50
		},
		{
			'T', 1ull << 40
		},
		{
			'G', 1ull << 30
		},
		{
			'M', 1ull << 20
		},
		{
			'K', 1ull << 10
		},
		{
			'0', 0
		},
	};

	char 		sym = 'B';
	uint64_t 	factor = 1;

	for (const struct unit * u = &units[0]; u->factor; ++u) {
		if (sz >= (u->factor * 9 / 10)) {
			sym = u->sym;
			factor = u->factor;
			break;
		}
	}

	const unsigned 	scaled10 = sz * 10 / factor;
	const unsigned 	scaled = sz / factor;
	if (scaled10 >= 1000) {
		printf("%u", scaled);
	} else if (scaled10 >= 100) {
		printf(" %u", scaled);
	} else {
		printf("%u.%u", scaled, scaled10 % 10);
	}

	putchar(sym);
	putchar(' ');
}

enum {
	FIELD_NAME = 0x01,
	FIELD_DUID = 0x02,
	FIELD_SIZE = 0x04,
	FIELD_USED = 0x08,
	FIELD_FREE = 0x10,
	FIELD_TYPE = 0x20,
	FIELD_COMMENT = 0x40,

	FIELD_DEFAULT = FIELD_NAME | FIELD_SIZE | FIELD_TYPE | FIELD_COMMENT,
};

enum {
	OPT_NOHEADER = 0x01,
	OPT_NOUNICODE = 0x02,
	OPT_NOBIO = 0x04,
};

struct my_diskinfo;

struct my_partinfo {
	char 		letter;
	uint64_t 	size;
	uint64_t 	fssize;
	uint64_t 	free;
	const char *fstype;
	const char *mount;
	const struct my_diskinfo *sub;
	  //If this is part of a RAID
			const char   *raidstatus;
	  //Only available if (sub != NULL)
		};

	struct my_diskinfo {
		char 		type [16];
		char 		label[16];
		char 		name [8];
		uint64_t 	size;
		uint64_t 	used;
		u_char 		duid   [8];
		uint8_t 	num_parts;
		struct my_partinfo parts[MAXPARTITIONS];
		const char *raidstatus;
		  //If this is a RAID device
	};

	struct padding {
		int 		name;
		/* duid = 8 */
		/* size = 4 */
		/* used = 4 */
		/* free = 4 */
		int 		type;
		int 		comment;
	};

	static void 	print_header(int fields, const struct padding * p) {
		if (fields & FIELD_NAME)
			printf("%-*s ", p->name, "NAME");

		if (fields & FIELD_DUID)
			printf("%-18s ", "DUID");

		if (fields & FIELD_SIZE)
			printf("%-4s ", "SIZE");

		if (fields & FIELD_USED)
			printf("%-4s ", "USED");

		if (fields & FIELD_FREE)
			printf("%-4s ", "FREE");

		if (fields & FIELD_TYPE)
			printf("%-*s ", p->type, "TYPE");

		if (fields & FIELD_COMMENT)
			printf("%-*s ", p->comment, "COMMENT");

#if WSDEBUG
		putchar('X');
#endif

		putchar('\n');
	}

	static void 	print_duid(const u_char * duid) {
		for (size_t i = 0; i < 8; ++i) {
			printf("%02x", duid[i]);
		}
	}

	static void 	print_disk(const struct my_diskinfo *, int, int, const char *, const struct padding *);
	static void 	print_part(
			  		const 	struct my_diskinfo * disk,
			  		const 	struct my_partinfo * part,
		int 		fields ,
		int 

Re: Supporting the OpenBSD Project through a Registered Charity

2023-09-01 Thread Charlie Jones


On 2023-08-29 21:14:43 Stuart Henderson  wrote:

>On 2023-08-29, Katherine Mcmillan  wrote:

>> To clarify, I'm looking for something with a similar structure at the US 
>> PostgreSQL

>> Association (which is a registered 501(c)(3) public charitable entity), but 
>> for BSD

>> or OpenBSD.

>I'm pretty sure there is nothing for OpenBSD like this.

Perhaps SPI (Software in the Public Interest) provides this capability

(if I understand correctly).  I discovered this when I tried to donate

to Libreoffice, which is headquartered in Germany.

>From SPI's wikipedia page:

   Software in the Public Interest, Inc. (SPI) is a US 501(c)(3)

non-profit organization domiciled in New York State formed to help

other organizations create and distribute free open-source software

and open-source hardware. Anyone is eligible to apply for membership,

and contributing membership is available to those who participate in

the free software community.

Their web page is:

    www.spi-inc.org

As nearly as I can tell, SPI handles all the paperwork and

interactions with the IRS, and allows people in the U.S. to donate to

a 501(c)3.  This gives the donor a tax benefit.  Donors who are used

to donating through a Donor Advised Fund are restricted by the DAF to

501(c)3 recipients.  So OpenBSD might possibly attract some new donors.

Katherine Mcmillan mentioned PostgreSQL.  I see on

    https://www.spi-inc.org/projects/

that PostgreSQL is one of the projects that already use SPI for its

donations.

The downside is that SPI charges 5% for this service.  It looks to me

like Paypal and the credit cards charge about half that, but they

don't provide 501(c)3 status.

I have no connection with SPI, other than donating through them, and I

don't know for sure how easy it would be for OpenBSD to interact with

them.  And I am not advocating for them, just mentioning their

existence on the off chance that people were not familiar with them.

-- Sent with https://mailfence.com  Secure and private email


openbgpd & openospfd woes

2023-09-01 Thread Skylar Gonzalez


Re: Supporting the OpenBSD Project through a Registered Charity

2023-09-01 Thread Stuart Henderson
On 2023-09-01, Charlie Jones  wrote:
>
> On 2023-08-29 21:14:43 Stuart Henderson  
> wrote:
>
>>On 2023-08-29, Katherine Mcmillan  wrote:
>
>>> To clarify, I'm looking for something with a similar structure at the US 
>>> PostgreSQL
>>> Association (which is a registered 501(c)(3) public charitable entity), but 
>>> for BSD
>>> or OpenBSD.
>
>>I'm pretty sure there is nothing for OpenBSD like this.
> 
> Perhaps SPI (Software in the Public Interest) provides this capability
>
>    Software in the Public Interest, Inc. (SPI) is a US 501(c)(3)
> non-profit organization domiciled in New York State formed to help
> other organizations create and distribute free open-source software
> and open-source hardware.

non-profit != charity

In most jurisdictions a charity has a bunch of extra responsibilities beyond 
those
placed on a non-profit which is not a charity.




pkg_add -u

2023-09-01 Thread latincom
Hello

i did an upgrade from 7.1 to 7.2, everything went well, but, i did an
upgrade from 7.2 to 7.3 and then i got this message:

ListUtil.c: loadable library and perl binaries are mismatched (got first
handshake key 0xec0, needed 0xeb8)

The procedure for both upgrades was:

# sysupgrade
# syspatch
# pkg_add -u

What is wrong, and how to repair it please?

Thanks.