From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 23 22:27:12 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 1634516A4A0 for ; Fri, 23 Jun 2006 22:27:12 +0000 (UTC) (envelope-from dmitry@atlantis.dp.ua) Received: from postman.atlantis.dp.ua (postman.atlantis.dp.ua [193.108.47.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6DC7943D6A for ; Fri, 23 Jun 2006 22:27:10 +0000 (GMT) (envelope-from dmitry@atlantis.dp.ua) Received: from smtp.atlantis.dp.ua (smtp.atlantis.dp.ua [193.108.46.231]) by postman.atlantis.dp.ua (8.13.1/8.13.1) with ESMTP id k5NMR5Qi003451 for ; Sat, 24 Jun 2006 01:27:05 +0300 (EEST) (envelope-from dmitry@atlantis.dp.ua) Date: Sat, 24 Jun 2006 01:27:05 +0300 (EEST) From: Dmitry Pryanishnikov To: freebsd-hackers@freebsd.org Message-ID: <20060624010644.Y82000@atlantis.atlantis.dp.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: mmap() vs. character special file 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: Fri, 23 Jun 2006 22:27:12 -0000 Hello! mmap(2) manpage has the following title: NAME mmap -- allocate memory, or map files or devices into memory I'm curious about mmap()ing devices (particularly, HDD slices). The manpage mentions character special files only once: [EINVAL] MAP_ANON has not been specified and fd did not refer- ence a regular or character special file. So it looks like one should be able to mmap() a character special file (w/o MAP_ANON, of course). However, if I try to issue: if ((fd=open(argv[1], O_RDWR)) == -1) err(EX_NOINPUT, "Can't open %s for readind and writing", argv[1]); if ((diskp=mmap(NULL, label_offset + sizeof (struct disklabel), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) err(EX_IOERR, "Can't mmap() file"); against /dev/adXsY (adXsY and adXsYZ are _not_ mounted), I'm getting EINVAL from mmap(). Is mmap()ping a disk slice/partition impossible by design, or it just isn't implemented yet? IMHO manpage doesn't reply to this question. Sincerely, Dmitry -- Atlantis ISP, System Administrator e-mail: dmitry@atlantis.dp.ua nic-hdl: LYNX-RIPE