From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 23 12:40:47 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 3A1B116A420 for ; Thu, 23 Feb 2006 12:40:47 +0000 (GMT) (envelope-from babkin@verizon.net) Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) by mx1.FreeBSD.org (Postfix) with ESMTP id 755D243D60 for ; Thu, 23 Feb 2006 12:40:42 +0000 (GMT) (envelope-from babkin@verizon.net) Received: from vms070.mailsrvcs.net ([192.168.1.3]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IV500KKW4JTIRS1@vms048.mailsrvcs.net> for freebsd-hackers@freebsd.org; Thu, 23 Feb 2006 06:40:41 -0600 (CST) Date: Thu, 23 Feb 2006 06:40:41 -0600 (CST) From: Sergey Babkin To: andrew clarke , freebsd-hackers@freebsd.org Message-id: <2491743.1140698441482.JavaMail.root@vms070.mailsrvcs.net> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Mailman-Approved-At: Fri, 24 Feb 2006 12:55:32 +0000 Cc: Subject: Re: volume serial number + volume label X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: babkin@users.sf.net List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2006 12:40:47 -0000 >From: andrew clarke > >How can I programmatically retrieve the "volume serial number" and >"volume label" of a removable disc in FreeBSD? This is the same >information that's presented by issuing a "dir" command in Windows: > > Volume in drive D is FooBar > Volume Serial Number is 58BB-96AA I've been reading on the Windows filesystems recently, so here is the quick answer: The serial number is contained in DOS/Windows partition's boot block, 8 bytes at offset 0x48. For the label you have to parse the DOS/Windows filseystem format. On FAT it's the name of the file in the root directory with the special attribute (VOL or LABEL - something like this, can't remember now). On NTFS it's stored I think as the attribute $VOLUME_NAME of the system file $Volume contained in the inode 3 of the Master File Table. -SB