diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-09-11 00:48:17 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-09-11 00:48:17 +0200 |
commit | 796f8789f80568861b747265998f31fa83091915 (patch) | |
tree | 292f120104d89fdfd20cb1105d9fdf889dbfb271 /storeio | |
parent | 17bd59544d8e3dccf33d3adebbc9df30842f022a (diff) | |
download | hurd-796f8789f80568861b747265998f31fa83091915.tar.gz hurd-796f8789f80568861b747265998f31fa83091915.tar.bz2 hurd-796f8789f80568861b747265998f31fa83091915.zip |
storeio: Avoid calling mmap with zero size
* storeio/dev.c (dev_open): When store is zero-sized, set buf to NULL
instead of calling mmap().
Diffstat (limited to 'storeio')
-rw-r--r-- | storeio/dev.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/storeio/dev.c b/storeio/dev.c index 78e0a177..8bdfa111 100644 --- a/storeio/dev.c +++ b/storeio/dev.c @@ -161,8 +161,11 @@ dev_open (struct dev *dev) to support this. */ store_set_flags (dev->store, STORE_INACTIVE); - dev->buf = mmap (0, dev->store->block_size, PROT_READ|PROT_WRITE, - MAP_ANON, 0, 0); + if (! dev->store->block_size) + dev->buf = NULL; + else + dev->buf = mmap (0, dev->store->block_size, PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); if (dev->buf == MAP_FAILED) { store_free (dev->store); |