From 0724e7ccf38469cae6551c5559471352e53897bb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 1 Feb 2015 07:24:16 -0600 Subject: [PATCH] drivers/ramdisk.c and include/nuttx/fs/ramdisk.h: Add logic to dispose of the drvier and RAM buffer when the RAM disk has been unlinked and all open references to the RAM disk have been closed. Add new parameters to romdisk() to specify what should be done with the RAM/ROM buffer -- Should it be freed or not? Changed all calls to ramdisk() to use these new parameters. --- examples/mount/ramdisk.c | 4 ++-- nshlib/nsh_fscmds.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/mount/ramdisk.c b/examples/mount/ramdisk.c index 21ec4c5e2..ded00c52b 100644 --- a/examples/mount/ramdisk.c +++ b/examples/mount/ramdisk.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/mount/ramdisk.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -116,7 +116,7 @@ int create_ramdisk(void) (FAR uint8_t *)pbuffer, CONFIG_EXAMPLES_MOUNT_NSECTORS, CONFIG_EXAMPLES_MOUNT_SECTORSIZE, - true); + RDFLAG_WRENABLED | RDFLAG_FUNLINK); if (ret < 0) { printf("create_ramdisk: Failed to register ramdisk at %s: %d\n", diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 34eb05c80..afde1e1c1 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -1250,7 +1250,8 @@ int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) /* Then register the ramdisk */ - ret = ramdisk_register(minor, buffer, nsectors, sectsize, true); + ret = ramdisk_register(minor, buffer, nsectors, sectsize, + RDFLAG_WRENABLED | RDFLAG_FUNLINK); if (ret < 0) { nsh_output(vtbl, g_fmtcmdfailed, argv[0], "ramdisk_register", NSH_ERRNO_OF(-ret));