erofs-utils: mount: add unmount support
PATCH 1/1 erofs-utils: mount: add unmount support
umount(8) may only unmount the filesystem without disconnecting the NBD device.
Add mount.erofs -u <DIR|BDEV> to manually disconnect devices for maintenance.
Signed-off-by Gao Xiang <[email protected]>
--- lib/backends/nbd.c | 10 ++++ lib/liberofs_nbd.h | 3 + mount/main.c | 134 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 138 insertions(+), 9 deletions(-)
lib/backends/nbd.c +10 -0
@@ -24,6 +24,7 @@#define NBD_DO_IT _IO( 0xab, 3 )#define NBD_CLEAR_SOCK _IO( 0xab, 4 )#define NBD_SET_SIZE_BLOCKS _IO( 0xab, 7 ) +#define NBD_DISCONNECT _IO( 0xab, 8 )#define NBD_SET_TIMEOUT _IO( 0xab, 9 )#define NBD_SET_FLAGS _IO( 0xab, 10)
@@ -221,3 +222,12 @@ int erofs_nbd_send_reply_header(int skfd, __le64 cookie, int err)return 0 ;return ret <0 ? -errno : -EIO ; } + +int erofs_nbd_disconnect (int nbdfd) +{ +int err, err2; + + err =ioctl (nbdfd,NBD_DISCONNECT ); + err2 =ioctl (nbdfd,NBD_CLEAR_SOCK ); +return err ?: err2; +}
lib/liberofs_nbd.h +3 -0
@@ -7,6 +7,8 @@#include "erofs/defs.h" +#define NBD_MAJOR 43/* Network block device */ +/* Supported request types */ enum {EROFS_NBD_CMD_READ =0 ,
@@ -35,5 +37,6 @@ int erofs_nbd_connect(int nbdfd, int blkbits, u64 blocks);int erofs_nbd_do_it (int nbdfd);int erofs_nbd_get_request (int skfd,struct erofs_nbd_request *rq);int erofs_nbd_send_reply_header (int skfd,__le64 cookie,int err); +int erofs_nbd_disconnect (int nbdfd);#endif
mount/main.c +125 -9
182 lines not on this page · raw message
Signature · 1 line
2.43.5