From: Ben Gras Date: Tue, 12 Jul 2011 16:09:52 +0000 (+0200) Subject: mfs<->vfs stat fallback for old vfs X-Git-Tag: v3.2.0~467 X-Git-Url: http://zhaoyanbai.com/repos/%22/xml/v3/mem/static/tz-link.htm?a=commitdiff_plain;h=253c2932135118c495861c0f6f71f7575158b8c7;p=minix.git mfs<->vfs stat fallback for old vfs --- diff --git a/servers/mfs/stadir.c b/servers/mfs/stadir.c index 0e980bdd4..915141d76 100644 --- a/servers/mfs/stadir.c +++ b/servers/mfs/stadir.c @@ -8,6 +8,24 @@ #include "super.h" #include +PRIVATE int copy_new_to_old_stat(endpoint_t who_e, + cp_grant_id_t gid, struct stat *st) +{ + struct minix_prev_stat prevst; + + memset(&prevst, 0, sizeof(prevst)); + + prevst.st_dev = st->st_dev; + prevst.st_ino = st->st_ino; + prevst.st_mode = st->st_mode; + prevst.st_uid = st->st_uid; + prevst.st_gid = st->st_gid; + prevst.st_size = st->st_size; + prevst.st_rdev = st->st_rdev; + + return sys_safecopyto(who_e, gid, (vir_bytes) 0, (vir_bytes) &prevst, + (size_t) sizeof(prevst), D); +} /*===========================================================================* * stat_inode * @@ -57,11 +75,17 @@ PRIVATE int stat_inode( /* Copy the struct to user space. */ r = sys_safecopyto(who_e, gid, (vir_bytes) 0, (vir_bytes) &statbuf, (size_t) sizeof(statbuf), D); + + /* Fallback for older VFS (old stat) */ + if(r != OK) { + r = copy_new_to_old_stat(who_e, gid, &statbuf); + if(r == OK) printf("MFS: old vfs stat fallback ok\n"); + else printf("MFS: old vfs stat fallback failed\n"); + } return(r); } - /*===========================================================================* * fs_fstatfs * *===========================================================================*/