From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 20 08:08:08 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBCC2106566C for ; Sat, 20 Feb 2010 08:08:08 +0000 (UTC) (envelope-from scdbackup@gmx.net) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 258F18FC08 for ; Sat, 20 Feb 2010 08:08:07 +0000 (UTC) Received: (qmail invoked by alias); 20 Feb 2010 07:41:25 -0000 Received: from 165.126.46.212.adsl.ncore.de (HELO 192.168.2.69) [212.46.126.165] by mail.gmx.net (mp066) with SMTP; 20 Feb 2010 08:41:25 +0100 X-Authenticated: #2145628 X-Provags-ID: V01U2FsdGVkX1+aD2oXCKiak/3p+5zx6lJQCBxq7uWi2PYwdDEFRd kN6I/VgCKGFyqN Date: Sat, 20 Feb 2010 08:43:27 +0100 From: "Thomas Schmitt" To: freebsd-hackers@freebsd.org Message-Id: <107129897910301@192.168.2.69> X-Y-GMX-Trusted: 0 X-FuHaFi: 0.53000000000000003 Subject: -reply:<4B7F7F02.1000004@freebsd.org> X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2010 08:08:08 -0000 Hi > I was looking at your Linux code here and thought > the technique of trying lseek(SEEK_END) might work. Linux 2.6.18, /dev/hda and /dev/sr0, with a CD-RW written by write type TAO lseek(fd, 0, SEEK_END)= 636499968 lseek(fd, -1, SEEK_END)= 636499967 lseek(fd, -300k, SEEK_END)= 636192768 and with a CD-ROM media: lseek(fd, 0, SEEK_END)= 618311680 lseek(fd, -1, SEEK_END)= 618311679 lseek(fd, -300k, SEEK_END)= 618004480 (No tape drive at hand. Sorry.) Nevertheless: SEEK_END brings you to the first unwritten address of the file object. With a read-only object, this address is not necessarily defined. Further: If you test a CD that was written by write type TAO, then the last two blocks of the track are no readable data blocks. It depends on the implementation of lseek() whether it will allow you to address bytes in those two blocks. (Read will fail, of course. On Linux it even fails shortly before the end because of the old TAO read-ahead bug.) So on CD i would test rather lseek() to an address that is several hundred kB before the end. 300 kB is the traditional fear-padding of CD burn programs on Linux. (On Linux i decide by stat(2). Considered as seekable are S_IFREG and S_IFBLK. Actually tested only with optical drives and USB sticks. To my knowledge ioctl(BLKGETSIZE) works only on S_IFBLK.) Have a nice day :) Thomas