statfs(), xforms, and linux

Robert S. Mallozzi (mallors@ips1.msfc.nasa.gov)
Fri, 25 Apr 1997 08:34:28 -0500

To subscribers of the xforms list from "Robert S. Mallozzi" <mallors@ips1.msfc.nasa.gov> :

Hi guys,

After pulling my hair out for a day, I finally isolated a problem
on my linux machine. However, I fail to understand why this error
occurs. If I use the statfs() function to obtain filesystem
information, xforms crashes with a seg fault. The test program below
illustrates the error. If I set do_xforms = 1, the program bombs under
linux when it tries to build a form. do_xforms = 0, and the program runs
normally. I tried it under IRIX 5.3, and do not get any errors.
Linux config:

xforms 0.86
libc 5.3.12
libX11 6.1
libm 5.0.6
kernel 2.0.27

The include files, and the call to statfs() must be changed for IRIX.
So that brings up another question: is it possible to get filesystem
info in a machine-independent way?

-bob

#include <sys/vfs.h>
#include "forms.h"

void util(void)
{
struct statfs *buf;

buf = (struct statfs *) malloc (sizeof(statfs));
if (buf == NULL) {
printf("could not malloc\n");
exit (1);
}

if (statfs("/", buf)) {
printf("statfs error\n");
exit (1);
}

printf("Filesystem size = %d blocks\n", buf->f_blocks);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void main (int argc, char **argv)
{
FL_FORM *form;
FL_OBJECT *obj;
int do_xforms = 0;

fl_initialize (&argc, argv, "test", 0, 0);

util();

if (do_xforms) {

form = fl_bgn_form(FL_UP_BOX, 200, 300);

obj = fl_add_text(FL_NORMAL_TEXT,
10, 10, 100, 30, "Text");

fl_end_form();

fl_show_form(form, FL_PLACE_CENTER, FL_FULLBORDER, "test");
fl_do_forms();

}

}

--
Dr. Robert S. Mallozzi
University of Alabama in Huntsville
http://cspar.uah.edu/~mallozzir/
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/