From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 8 12:23:57 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 46C1037B401 for ; Tue, 8 Jul 2003 12:23:57 -0700 (PDT) Received: from intarweb.us (pool-138-88-176-214.res.east.verizon.net [138.88.176.214]) by mx1.FreeBSD.org (Postfix) with SMTP id 273B143FA3 for ; Tue, 8 Jul 2003 12:23:56 -0700 (PDT) (envelope-from exarkun@intarweb.us) Received: from meson ([127.0.0.1]) by meson with smtp (Twisted 1.0.6) for hackers@freebsd.org; Tue, 08 Jul 2003 15:23:54 -0400 Date: Tue, 8 Jul 2003 15:23:53 -0400 From: Jp Calderone To: hackers@freebsd.org Message-ID: <20030708192342.GA4899@intarweb.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.25i Subject: telldir()/seekdir() confusion X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jul 2003 19:23:57 -0000 I'm trying to work out some inconsistent behavior in my app across platforms. On FreeBSD, seekdir() doesn't seem to behave as I expect it to. Here's a short program that demonstrates my confusion: #include #include #include int main() { DIR* dirp; off_t pos; struct dirent* ent; dirp = opendir("."); if (!dirp) perror("opendir"); ent = readdir(dirp); if (!ent) perror("readdir"); pos = telldir(dirp); if (pos == -1) perror("telldir"); ent = readdir(dirp); if (!ent) perror("readdir 2"); seekdir(dirp, pos); printf("First telldir:%d\nSecond telldir:%d\n", pos, telldir(dirp)); return 0; } On other platforms, the first and second telldir() return the same value. On the two FreeBSD machines I've tried it on, the first telldir() returns 1 and the second returns 0. Can anyone explain this? Thanks in advance, Jp