*BSD News Article 98108


Return to BSD News archive

Newsgroups: comp.unix.bsd.freebsd.misc
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!uunet!in3.uu.net!128.230.129.106!news.maxwell.syr.edu!cam-news-hub1.bbnplanet.com!su-news-feed4.bbnplanet.com!news.bbnplanet.com!news.nttlabs.com!fuji2.slab.ntt.co.jp!lancer!eclnews!sinetnews!newssinet!ccews7!decpc5.math.okayama-u.ac.jp!pine
From: Hiroaki Komatsu <pine@math.okayama-u.ac.jp>
Subject: [Q] NFS + mmap
Sender: newsmaster@cc.okayama-u.ac.jp (News System Admin)
Message-ID: <Pine.BSF.3.95LJ1.1b3.970620162341.1331C-100000@decpc5.math.okayama-u.ac.jp>
Date: Fri, 20 Jun 1997 07:25:09 GMT
Content-Type: TEXT/PLAIN; charset=US-ASCII
Mime-Version: 1.0
Organization: Okayama University, Japan
Lines: 42
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:43201

I have a problem about NFS.  I am using machines running
FreeBSD 2.1.0-RELEASE or 2.2.2-RELEASE, and NFS server is
SPARC station 20 running SunOS 4.1.3.

The problem occurs whenever an argument, say `foo', of the
following program is a remote file via NFS.  While the
program is sleeping 10 seconds, if another machine executes
`echo >foo' then write() call can not return.

------------------------------------------------------------
#include <stdio.h>
#include <sys/mman.h>

main(int argc, char *argv[])
{
  FILE *fin;
  char *buf;

  if (argc != 2 || (fin = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Usage: %s file\n", argv[0]);
    exit(-1);
  }
  fprintf(stderr, "sleep 10 seconds ...\n");
  sleep(10);
  buf = mmap(0, 1, PROT_READ, MAP_SHARED, fileno(fin), 0);
  if ((int)buf < 0) {
    fprintf(stderr, "? mmap\n");
    exit(-1);
  }
  write(1, buf, 1);
}
------------------------------------------------------------

I do not know wheather this is a problem peculiar to my
environment or not.  Is this an unavoidable facts?  Please
tell me the truth.

--
Hiroaki Komatsu (pine@math.okayama-u.ac.jp)
Okayama University
Graduate School of Natural Science and Technology