diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-02-03 20:22:59 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-02-03 20:22:59 +0000 |
commit | 733a208183bae4377a3fed494fa202e728958118 (patch) | |
tree | 2013241b2f265158f46de7d66427e186de851894 /libdiskfs/conch-fetch.c | |
parent | f3449a0f59a3434ffed43093662d88a2cac75781 (diff) |
Formerly conch-fetch.c.~2~
Diffstat (limited to 'libdiskfs/conch-fetch.c')
-rw-r--r-- | libdiskfs/conch-fetch.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libdiskfs/conch-fetch.c b/libdiskfs/conch-fetch.c index 17719bd3..c4839ba3 100644 --- a/libdiskfs/conch-fetch.c +++ b/libdiskfs/conch-fetch.c @@ -16,6 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "priv.h" +#include <hurd/ioserver.h> /* Update our copy of the relevant fields from a shared page. Callers must have the share lock on the shared page as well as the inode @@ -26,15 +27,26 @@ ioserver_fetch_shared_data (void *arg) { struct protid *cred = arg; + /* Don't allow the user to grow the file past the alloc size. */ + if (cred->mapped->file_size > cred->po->np->allocsize) + cred->mapped->file_size = cred->po->np->allocsize; + + /* Don't allow the user to truncate the file this way. */ if (cred->mapped->file_size < cred->po->np->dn_stat.st_size) cred->mapped->file_size = cred->po->np->dn_stat.st_size; - else if (cred->po->np->dn_stat.st_size != cred->mapped->file_size - && !readonly) + else if (cred->po->np->dn_stat.st_size != cred->mapped->file_size) { - cred->po->np->dn_stat.st_size = cred->mapped->file_size; - cred->po->np->dn_set_ctime = 1; + /* The user can validly set the size, but block the attempt + if we are readonly. */ + if (readonly) + cred->mapped->file_size = cred->po->np->dn_stat.st_size; + else + { + cred->po->np->dn_stat.st_size = cred->mapped->file_size; + cred->po->np->dn_set_ctime = 1; + } } - + cred->po->filepointer = cred->mapped->xx_file_pointer; if (!readonly) |