Skip Menu |

This queue is for tickets about the File-Map CPAN distribution.

Report information
The Basics
Id: 52950
Status: resolved
Priority: 0/
Queue: File-Map

People
Owner: LEONT [...] cpan.org
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.20
Fixed in: (no value)



Subject: not only regular files mappable
Date: Tue, 22 Dec 2009 08:29:46 +1100
To: bug-File-Map [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
In File::Map 0.20 a program use strict; use warnings; use File::Map 'map_file'; my $filename = '/dev/null'; my $str; map_file ($str, $filename, '<'); gets an error Could not map: handle doesn't refer to a file at /home/gg/bug/file-map-dev/foo.pl line 7 which is misleading when it says "could not map", as it is in fact possible to map a non-file like /dev/null. In is_stattable() I believe there's no need to demand an ordinary file before looking at st_size. On char specials it's zero (or sometimes how many bytes are queued for reading, supposedly). I believe it will be simpler to have it how it was before, were an omitted size to map_file() means get it from st_size. A caller who suspects st_size might not be a good value can take steps, but File::Map needn't disallow outright. (Testing file types is generally not a good idea of course -- you don't want program or library code presuming to know the types of files the system can or can't operate on ...)
Hi Kevin, I looked things up and it seems you're right: character devices can be mmap()ed. I'll update it in the next version, though I'm keeping the check against FIFOs and sockets. It will be changed in the next version. Regards, Leon