[comp.unix.ultrix] problem with gethostname

robm@janus.Berkeley.EDU (Rob McNicholas) (01/26/91)

Hi,

I am trying to get nfswatch running on my DECstation 3100 (24 meg,
ultrix 4.1, Rev. 52).  However, the program always immediately exits
with a "No such file or directory" error.  Using gdb, I have
traced the error down to a "gethostname" call.  When run from the
debugger, I get this output:

(gdb)
154             if (gethostname(myhost, sizeof(myhost)) < 0) {
(gdb)
gethostname () (../gethostname.s line 18)
../gethostname.s: No such file or directory.


Anyone have any ideas?

Thanks in advance,

- Rob

Rob McNicholas			Computer Systems Support Group, U.C. Berkeley
robm@janus.berkeley.edu		....!ucbvax!janus!robm
Home: 415/339-1514		Work: 415/642-8633

mogul@wrl.dec.com (Jeffrey Mogul) (01/26/91)

In article <40589@ucbvax.BERKELEY.EDU> robm@janus.Berkeley.EDU (Rob McNicholas) writes:
>I am trying to get nfswatch running on my DECstation 3100 (24 meg,
>ultrix 4.1, Rev. 52).  However, the program always immediately exits
>with a "No such file or directory" error.  Using gdb, I have
>traced the error down to a "gethostname" call.  When run from the
>debugger, I get this output:
>
>(gdb)
>154             if (gethostname(myhost, sizeof(myhost)) < 0) {
>(gdb)
>gethostname () (../gethostname.s line 18)
>../gethostname.s: No such file or directory.

I don't use gdb, but almost certainly the "No such file or directory"
message you are getting from gdb has nothing to do with the "No such file
or directory" message you are getting from nfswatch.  Gdb is merely
telling you that it cannot find the source file for the gethostname()
function.  The gethostname() system call cannot return this error code.

My guess is that your error comes when the program tries to open the
packet filter pseudo-device.  Before you can use nfswatch (or similar
programs such as tcpdump), you must
	(1) configure your kernel to include the packet filter
		("man 4 packetfilter" for details.)
	(2) create the proper entries in /dev/pf (again, "man 4
		packetfilter")
	(3) do "/usr/etc/pfconfig +p -a" ("man 8 pfconfig")
(Failing to do step #3 will not cause your error message, it will
simply cause the program to be very boring.)

-Jeff

jenny@baker.dartmouth.edu (Jennifer Merrill) (01/29/91)

No doubt you are going to think this is crazy, but we had the same problem
when we moved or code from a Vax running 4.3BSD to a 5810 running Ultrix
3.? (I can't remember which).

It turned out, in our case, that the problem was conflicting variables.  I
had a program with a global array called 'databases'.  I eventually found out
that the routine getsvc also has a variable called 'databases'.  (I found
this by doing a nm(1) on libc.a.)  As I filled in my array, I trashed
the getsvc's version of databases and eventually that system call failed.

I'm not familiar with the program nfswatch, but my suggestion would be
to do an nm on the binary and see if you find any conflicts.  Find out what
variables are used by gethostname (and the routines it calls) and then see
if you've got any of those in nfswatch.

Good luck!!

---
Jennifer K. Merrill      (Jennifer.Merrill@dartmouth.edu)
Library Computing Services
Dartmouth College

--
---
Jennifer K. Merrill      (Jennifer.Merrill@dartmouth.edu)
Library Computing Services
Dartmouth College