Fixed compiling on NetBSD 3.1

This commit is contained in:
Michiel Broek 2007-08-26 14:02:27 +00:00
parent c78578675c
commit 52ec72ec15
7 changed files with 63 additions and 5 deletions

View File

@ -26,22 +26,25 @@ v0.91.10 21-Aug-2007
mbcico: mbcico:
Fixed a lot of compiler warnings. Fixed a lot of compiler warnings.
Fixed compiling on NetBSD 3.1.
mbfido: mbfido:
Fixed a lot of compiler warnings. Fixed a lot of compiler warnings.
Fixed compiling on NetBSD 3.1.
mbdiff: mbdiff:
Fixed a lot of compiler warnings. Fixed a lot of compiler warnings.
mbsebbs: mbsebbs:
Fixed a lot of compiler warnings. Fixed a lot of compiler warnings.
Fixed compiling on NetBSD 3.1.
mbmon: mbmon:
Added support or the ARM processor. Added support or the ARM processor.
mbtask: mbtask:
Added support or the ARM processor. Added support or the ARM processor.
Fixed compiling on NetBSD 3.1.
v0.91.9 16-May-2007 - 21-Aug-2007 v0.91.9 16-May-2007 - 21-Aug-2007

View File

@ -1053,7 +1053,11 @@ int file_transfer(void)
TrType binkp_receiver(void) TrType binkp_receiver(void)
{ {
#ifdef __NetBSD__
struct statvfs sfs;
#else
struct statfs sfs; struct statfs sfs;
#endif
int written; int written;
off_t rxbytes; off_t rxbytes;
int bcmd, rc = 0; int bcmd, rc = 0;
@ -1208,7 +1212,11 @@ TrType binkp_receiver(void)
return Failure; return Failure;
} }
#ifdef __NetBSD__
if (statvfs(tempinbound, &sfs) == 0) {
#else
if (statfs(tempinbound, &sfs) == 0) { if (statfs(tempinbound, &sfs) == 0) {
#endif
if ((bp.rsize / (sfs.f_bsize + 1)) >= sfs.f_bfree) { if ((bp.rsize / (sfs.f_bsize + 1)) >= sfs.f_bfree) {
Syslog('!', "Binkp: only %u blocks free (need %u) in %s for this file", sfs.f_bfree, Syslog('!', "Binkp: only %u blocks free (need %u) in %s for this file", sfs.f_bfree,
(unsigned int)(bp.rsize / (sfs.f_bsize + 1)), tempinbound); (unsigned int)(bp.rsize / (sfs.f_bsize + 1)), tempinbound);

View File

@ -198,9 +198,15 @@ int inbound_close(int success)
*/ */
int inbound_space(void) int inbound_space(void)
{ {
#ifdef __NetBSD__
struct statvfs sfs;
if (statvfs(tempinbound, &sfs) != 0) {
#else
struct statfs sfs; struct statfs sfs;
if (statfs(tempinbound, &sfs) != 0) { if (statfs(tempinbound, &sfs) != 0) {
#endif
Syslog('!', "Cannot statfs \"%s\", assume enough space", tempinbound); Syslog('!', "Cannot statfs \"%s\", assume enough space", tempinbound);
return -1L; return -1L;
} else } else

View File

@ -558,6 +558,15 @@ int putsec(char *buf, int n)
int getfree(void) int getfree(void)
{ {
#ifdef __NetBSD__
struct statvfs sfs;
if (statvfs(inbound, &sfs) != 0) {
WriteError("$cannot statvfs \"%s\", assume enough space", inbound);
return -1L;
} else
return (sfs.f_bsize * sfs.f_bfree);
#else
struct statfs sfs; struct statfs sfs;
if (statfs(inbound, &sfs) != 0) { if (statfs(inbound, &sfs) != 0) {
@ -565,6 +574,7 @@ int getfree(void)
return -1L; return -1L;
} else } else
return (sfs.f_bsize * sfs.f_bfree); return (sfs.f_bsize * sfs.f_bfree);
#endif
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Unpacker * Purpose ...............: Unpacker
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2007
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -43,9 +43,15 @@ extern int do_quiet;
int checkspace(char *dir, char *fn, int factor) int checkspace(char *dir, char *fn, int factor)
{ {
struct stat st; struct stat st;
#ifdef __NetBSD__
struct statvfs sfs;
if ((stat(fn,&st) != 0) || (statvfs(dir,&sfs) != 0)) {
#else
struct statfs sfs; struct statfs sfs;
if ((stat(fn,&st) != 0) || (statfs(dir,&sfs) != 0)) { if ((stat(fn,&st) != 0) || (statfs(dir,&sfs) != 0)) {
#endif
WriteError("Cannot stat \"%s\" or statfs \"%s\", assume enough space", fn, dir); WriteError("Cannot stat \"%s\" or statfs \"%s\", assume enough space", fn, dir);
return 1; return 1;
} }

View File

@ -614,13 +614,21 @@ int putsec(char *buf, int n)
int getfree(void) int getfree(void)
{ {
#ifdef __NetBSD__
struct statvfs sfs;
#else
struct statfs sfs; struct statfs sfs;
#endif
char *temp; char *temp;
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
snprintf(temp, PATH_MAX, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
#ifdef __NetBSD__
if (statvfs(temp, &sfs) != 0) {
#else
if (statfs(temp, &sfs) != 0) { if (statfs(temp, &sfs) != 0) {
#endif
WriteError("$cannot statfs \"%s\", assume enough space", temp); WriteError("$cannot statfs \"%s\", assume enough space", temp);
free(temp); free(temp);
return -1L; return -1L;

View File

@ -321,12 +321,20 @@ void disk_getfs_r(char *buf)
*/ */
void update_diskstat(void) void update_diskstat(void)
{ {
#ifdef __NetBSD__
struct statvfs sfs;
#else
struct statfs sfs; struct statfs sfs;
#endif
unsigned int temp; unsigned int temp;
mfs_list *tmp; mfs_list *tmp;
for (tmp = mfs; tmp; tmp = tmp->next) { for (tmp = mfs; tmp; tmp = tmp->next) {
#ifdef __NetBSD__
if (statvfs(tmp->mountpoint, &sfs) == 0) {
#else
if (statfs(tmp->mountpoint, &sfs) == 0) { if (statfs(tmp->mountpoint, &sfs) == 0) {
#endif
temp = (unsigned int)(sfs.f_bsize / 512L); temp = (unsigned int)(sfs.f_bsize / 512L);
tmp->size = (unsigned int)(sfs.f_blocks * temp) / 2048L; tmp->size = (unsigned int)(sfs.f_blocks * temp) / 2048L;
tmp->avail = (unsigned int)(sfs.f_bavail * temp) / 2048L; tmp->avail = (unsigned int)(sfs.f_bavail * temp) / 2048L;
@ -337,11 +345,16 @@ void update_diskstat(void)
* See man 2 statvfs about what approximately is defined. * See man 2 statvfs about what approximately is defined.
*/ */
tmp->ro = (strstr(tmp->fstype, "iso") != NULL); tmp->ro = (strstr(tmp->fstype, "iso") != NULL);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__) || defined(__OpenBSD__)
/* /*
* XxxxBSD has the info in the statfs structure. * XxxxBSD has the info in the statfs structure.
*/ */
tmp->ro = (sfs.f_flags & MNT_RDONLY); tmp->ro = (sfs.f_flags & MNT_RDONLY);
#elif defined(__NetBSD__)
/*
* NetBSD 3.1 is a bit different again
*/
tmp->ro = (sfs.f_flag & ST_RDONLY);
#else #else
#error "Don't know how to get sfs read-only status" #error "Don't know how to get sfs read-only status"
#endif #endif
@ -362,10 +375,14 @@ void add_path(char *lpath)
#if defined(__linux__) #if defined(__linux__)
char *mtab, *fs; char *mtab, *fs;
FILE *fp; FILE *fp;
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__) || defined(__OpenBSD__)
struct statfs *mntbuf; struct statfs *mntbuf;
int mntsize; int mntsize;
int i; int i;
#elif defined(__NetBSD__)
struct statvfs *mntbuf;
int mntsize;
int i;
#else #else
#error "Don't know how to get mount paths" #error "Don't know how to get mount paths"
#endif #endif