From 834580b49008057cf4f1ab54595b86b6499a79e0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 1 May 1999 06:05:22 +0000 Subject: 1999-04-30 Mark Kettenis * storeio.c (trivfs_modify_stat): Do not assume that we have the device open in the caculation of st_mode. If the device is not open, only return S_IFCHR if inhibit_cache is set. --- storeio/storeio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'storeio') diff --git a/storeio/storeio.c b/storeio/storeio.c index 600fbb57..afd654bb 100644 --- a/storeio/storeio.c +++ b/storeio/storeio.c @@ -230,6 +230,8 @@ trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) { struct open *open = cred->po->hook; + st->st_mode &= ~S_IFMT; + if (open) /* An open device. */ { @@ -241,6 +243,9 @@ trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) st->st_size = size; st->st_blocks = size / 512; + + st->st_mode |= ((inhibit_cache || store->block_size == 1) + ? S_IFCHR : S_IFBLK); } else /* Try and do things without an open device... */ @@ -248,12 +253,10 @@ trivfs_modify_stat (struct trivfs_protid *cred, struct stat *st) st->st_blksize = 0; st->st_size = 0; st->st_blocks = 0; + + st->st_mode |= inhibit_cache ? S_IFCHR : S_IFBLK; } - st->st_mode &= ~S_IFMT; - st->st_mode |= ((open->dev->inhibit_cache - || open->dev->store->block_size == 1) - ? S_IFCHR : S_IFBLK); st->st_rdev = rdev; if (readonly) st->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); -- cgit v1.2.3