diff --git a/fs/binfs/fs_binfs.c b/fs/binfs/fs_binfs.c index a130a01999..a5cca2aa24 100644 --- a/fs/binfs/fs_binfs.c +++ b/fs/binfs/fs_binfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/binfs/fs_binfs.c * - * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -370,7 +370,8 @@ static int binfs_bind(FAR struct inode *blkdriver, const void *data, * ****************************************************************************/ -static int binfs_unbind(void *handle, FAR struct inode **blkdriver) +static int binfs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags) { fvdbg("Entry\n"); return OK; diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index 5cb58463a3..7dd24c7337 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_fat32.c * - * Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -97,7 +97,8 @@ static int fat_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir); static int fat_bind(FAR struct inode *blkdriver, const void *data, void **handle); -static int fat_unbind(void *handle, FAR struct inode **blkdriver); +static int fat_unbind(void *handle, FAR struct inode **blkdriver, + unsigned int flags); static int fat_statfs(struct inode *mountpt, struct statfs *buf); static int fat_unlink(struct inode *mountpt, const char *relpath); @@ -116,7 +117,7 @@ static int fat_stat(struct inode *mountpt, const char *relpath, struct stat * Public Variables ****************************************************************************/ -/* See fs_mount.c -- this structure is explicitly externed there. +/* See fs_mount.c -- this structure is explicitly extern'ed there. * We use the old-fashioned kind of initializers so that this will compile * with any compiler. */ @@ -197,7 +198,7 @@ static int fat_open(FAR struct file *filep, const char *relpath, ret = fat_finddirentry(fs, &dirinfo, relpath); - /* Three possibililities: (1) a node exists for the relpath and + /* Three possibilities: (1) a node exists for the relpath and * dirinfo describes the directory entry of the entity, (2) the * node does not exist, or (3) some error occurred. */ @@ -1795,7 +1796,8 @@ static int fat_bind(FAR struct inode *blkdriver, const void *data, * ****************************************************************************/ -static int fat_unbind(void *handle, FAR struct inode **blkdriver) +static int fat_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags) { struct fat_mountpt_s *fs = (struct fat_mountpt_s*)handle; int ret; @@ -1811,9 +1813,13 @@ static int fat_unbind(void *handle, FAR struct inode **blkdriver) fat_semtake(fs); if (fs->fs_head) { - /* We cannot unmount now.. there are open files */ + /* We cannot unmount now.. there are open files + * + * This implementation currently only supports unmounting if there are + * no open file references. + */ - ret = -EBUSY; + ret = (flags != 0) ? -ENOSYS : -EBUSY; } else { diff --git a/fs/mount/fs_umount2.c b/fs/mount/fs_umount2.c index 6d0609f9ed..1611bb6dca 100644 --- a/fs/mount/fs_umount2.c +++ b/fs/mount/fs_umount2.c @@ -92,7 +92,7 @@ int umount2(FAR const char *target, unsigned int flags) FAR struct inode *mountpt_inode; FAR struct inode *blkdrvr_inode = NULL; int errcode = OK; - int status; + int ret; /* Verify required pointer arguments */ @@ -137,15 +137,16 @@ int umount2(FAR const char *target, unsigned int flags) */ inode_semtake(); /* Hold the semaphore through the unbind logic */ - status = mountpt_inode->u.i_mops->unbind( mountpt_inode->i_private, &blkdrvr_inode); - if (status < 0) + ret = mountpt_inode->u.i_mops->unbind(mountpt_inode->i_private, + &blkdrvr_inode, flags); + if (ret < 0) { /* The inode is unhappy with the blkdrvr for some reason */ - errcode = -status; + errcode = -ret; goto errout_with_semaphore; } - else if (status > 0) + else if (ret > 0) { errcode = EBUSY; goto errout_with_semaphore; @@ -160,16 +161,16 @@ int umount2(FAR const char *target, unsigned int flags) * there is still at least reference on it (from the mount) */ - status = inode_remove(target); + ret = inode_remove(target); inode_semgive(); /* The return value of -EBUSY is normal (in fact, it should * not be OK) */ - if (status != OK && status != -EBUSY) + if (ret != OK && ret != -EBUSY) { - errcode = -status; + errcode = -ret; goto errout_with_mountpt; } diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c index bb42093de2..c9536f44af 100644 --- a/fs/nfs/nfs_vfsops.c +++ b/fs/nfs/nfs_vfsops.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nfs/nfs_vfsops.c * - * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved. * Author: Jose Pablo Rojas Vargas * Gregory Nutt @@ -144,7 +144,8 @@ static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt, FAR struct nfs_args *argp); static int nfs_bind(FAR struct inode *blkdriver, const void *data, void **handle); -static int nfs_unbind(void *handle, FAR struct inode **blkdriver); +static int nfs_unbind(void *handle, FAR struct inode **blkdriver. + unsigned int flags); static int nfs_statfs(struct inode *mountpt, struct statfs *buf); static int nfs_remove(struct inode *mountpt, const char *relpath); static int nfs_mkdir(struct inode *mountpt, const char *relpath, @@ -1872,7 +1873,8 @@ bad: * ****************************************************************************/ -int nfs_unbind(FAR void *handle, FAR struct inode **blkdriver) +int nfs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags) { FAR struct nfsmount *nmp = (FAR struct nfsmount *)handle; int error; @@ -1893,7 +1895,12 @@ int nfs_unbind(FAR void *handle, FAR struct inode **blkdriver) if (nmp->nm_head != NULL) { fdbg("ERROR; There are open files: %p\n", nmp->nm_head); - error = EBUSY; + + /* This implementation currently only supports unmounting if there are + * no open file references. + */ + + error = (flags != 0) ? ENOSYS : EBUSY; goto errout_with_semaphore; } diff --git a/fs/nxffs/nxffs.h b/fs/nxffs/nxffs.h index 87bc062275..89adb6dac1 100644 --- a/fs/nxffs/nxffs.h +++ b/fs/nxffs/nxffs.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nxffs/nxffs.h * - * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: Linux/Documentation/filesystems/romfs.txt @@ -1098,7 +1098,8 @@ int nxffs_readdir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); int nxffs_rewinddir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir); int nxffs_bind(FAR struct inode *blkdriver, FAR const void *data, FAR void **handle); -int nxffs_unbind(FAR void *handle, FAR struct inode **blkdriver); +int nxffs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags); int nxffs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf); int nxffs_stat(FAR struct inode *mountpt, FAR const char *relpath, FAR struct stat *buf); diff --git a/fs/nxffs/nxffs_initialize.c b/fs/nxffs/nxffs_initialize.c index d7d55f077a..13081b6c1d 100644 --- a/fs/nxffs/nxffs_initialize.c +++ b/fs/nxffs/nxffs_initialize.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/nxffs/nxffs_initialize.c * - * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: Linux/Documentation/filesystems/romfs.txt @@ -550,11 +550,21 @@ int nxffs_bind(FAR struct inode *blkdriver, FAR const void *data, * ****************************************************************************/ -int nxffs_unbind(FAR void *handle, FAR struct inode **blkdriver) +int nxffs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags) { #ifndef CONFIG_NXFFS_PREALLOCATED # error "No design to support dynamic allocation of volumes" #else + /* This implementation currently only supports unmounting if there are no + * open file references. + */ + + if (flags != 0) + { + return -ENOSYS; + } + return g_volume.ofiles ? -EBUSY : OK; #endif } diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 3225736918..0ecab35402 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/procfs/fs_procfs.c * - * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -170,7 +170,8 @@ static int procfs_rewinddir(FAR struct inode *mountpt, static int procfs_bind(FAR struct inode *blkdriver, FAR const void *data, FAR void **handle); -static int procfs_unbind(FAR void *handle, FAR struct inode **blkdriver); +static int procfs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags); static int procfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf); @@ -861,7 +862,8 @@ static int procfs_bind(FAR struct inode *blkdriver, const void *data, * ****************************************************************************/ -static int procfs_unbind(void *handle, FAR struct inode **blkdriver) +static int procfs_unbind(void *handle, FAR struct inode **blkdriver, + unsigned int flags) { return OK; } diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c index c4f41f2d27..3a65adfc2b 100644 --- a/fs/romfs/fs_romfs.c +++ b/fs/romfs/fs_romfs.c @@ -92,7 +92,8 @@ static int romfs_rewinddir(FAR struct inode *mountpt, static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data, FAR void **handle); -static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver); +static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags); static int romfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf); @@ -977,7 +978,8 @@ errout_with_sem: * ****************************************************************************/ -static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver) +static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags) { FAR struct romfs_mountpt_s *rm = (FAR struct romfs_mountpt_s*)handle; int ret; @@ -999,7 +1001,12 @@ static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver) /* We cannot unmount now.. there are open files */ fdbg("There are open files\n"); - ret = -EBUSY; + + /* This implementation currently only supports unmounting if there are + * no open file references. + */ + + ret = (flags != 0) ? -ENOSYS : -EBUSY; } else { diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c index bf1490ee0d..857c284e2b 100644 --- a/fs/smartfs/smartfs_smart.c +++ b/fs/smartfs/smartfs_smart.c @@ -93,7 +93,8 @@ static int smartfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) static int smartfs_bind(FAR struct inode *blkdriver, const void *data, void **handle); -static int smartfs_unbind(void *handle, FAR struct inode **blkdriver); +static int smartfs_unbind(void *handle, FAR struct inode **blkdriver, + unsigned int flags); static int smartfs_statfs(struct inode *mountpt, struct statfs *buf); static int smartfs_unlink(struct inode *mountpt, const char *relpath); @@ -1544,7 +1545,8 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data, * ****************************************************************************/ -static int smartfs_unbind(void *handle, FAR struct inode **blkdriver) +static int smartfs_unbind(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags) { struct smartfs_mountpt_s *fs = (struct smartfs_mountpt_s*)handle; int ret; @@ -1564,7 +1566,11 @@ static int smartfs_unbind(void *handle, FAR struct inode **blkdriver) smartfs_semgive(fs); - ret = -EBUSY; + /* This implementation currently only supports unmounting if there are + * no open file references. + */ + + return (flags != 0) ? -ENOSYS : -EBUSY; } else { @@ -1575,7 +1581,6 @@ static int smartfs_unbind(void *handle, FAR struct inode **blkdriver) smartfs_semgive(fs); kmm_free(fs); - return ret; } diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 0b6a7d9289..dd71e6222e 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/fs/fs.h * - * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -196,7 +196,8 @@ struct mountpt_operations int (*bind)(FAR struct inode *blkdriver, FAR const void *data, FAR void **handle); - int (*unbind)(FAR void *handle, FAR struct inode **blkdriver); + int (*unbind)(FAR void *handle, FAR struct inode **blkdriver, + unsigned int flags); int (*statfs)(FAR struct inode *mountpt, FAR struct statfs *buf); /* Operations on paths */