diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mfs_subr.c | 2 | ||||
| -rwxr-xr-x | src/mfs_vnops.c | 15 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/mfs_subr.c b/src/mfs_subr.c index b83c75d..420046b 100644 --- a/src/mfs_subr.c +++ b/src/mfs_subr.c @@ -62,6 +62,8 @@ char *mfs_get_home_path(const char *extra) char *res; const char *home = getenv("HOME"); + if (home == NULL) + return (NULL); hlen = strlen(home); exlen = (extra != NULL) ? strlen(extra) : 0; diff --git a/src/mfs_vnops.c b/src/mfs_vnops.c index 9af8a2f..da23177 100755 --- a/src/mfs_vnops.c +++ b/src/mfs_vnops.c @@ -42,6 +42,7 @@ static int mfs_getattr (const char *path, struct stat *stbuf) { char *realpath; + int res; int status = 0; memset (stbuf, 0, sizeof (struct stat)); @@ -56,7 +57,7 @@ static int mfs_getattr (const char *path, struct stat *stbuf) char *mfsrc = mfs_get_home_path(".mfsrc"); if (mfsrc == NULL) return (-ENOMEM); - int res = stat(mfsrc, stbuf); + res = stat(mfsrc, stbuf); DEBUG("stat result for %s: %d\n", mfsrc, res); free(mfsrc); return (res); @@ -75,17 +76,11 @@ static int mfs_getattr (const char *path, struct stat *stbuf) status = mfs_realpath(path, &realpath); if (status != 0) return status; - if (stat(realpath, stbuf) != 0) { - free(realpath); - return -ENOENT; - } + res = stat(realpath, stbuf); free(realpath); - return 0; - - case MFS_NOTFOUND: - default: - return -ENOENT; + return (res); } + return (-ENOENT); } |
