Please add a subject to the PR titles
To help filter the emails Please add a subject to the PR titles Fix compile break ---> readline:Fix compile break
Re: Please add a subject to the PR titles
I agree. I just changed the title to two PRs to follow this. I also added this to CONTRIBUTING.md: https://github.com/apache/incubator-nuttx/pull/2334 Best, Matias On Wed, Nov 18, 2020, at 10:25, David Sidrane wrote: > To help filter the emails > > Please add a subject to the PR titles > > Fix compile break ---> readline:Fix compile break >
Remove Device Nodes
Hello all, I have a question regarding the device nodes from /dev folder. The sequence I execute is the following: 1. smart_initialize method - creates /dev/smart1d file *mtd_part = mtd_partition(mtd, partoffset, (partsize >> 2) * 8); smart_initialize(1, mtd_part, partname);* * mount("/dev/smart1d", "/mnt/smart", "smartfs", 0, NULL);* 2. ftl_initialize and bchdev_register - create /dev/mtd1 and /dev/mtdblock1 *mtd_part2 = mtd_partition(mtd, partoffset, (partsize>>2)*8); ftl_initialize(1, mtd_part2); snprintf(blockname, 32, "/dev/mtdblock%d", 1); snprintf(charname, 32, "/dev/mtd%d", 1); bchdev_register(blockname, charname, false);* Is there a way to remove the device nodes(files) from /dev folder? For the second step I found *int bchdev_unregister(FAR const char *chardev),* which removes only */dev/mtd1 *node. For the first step, *unregister_driver() *can be called to remove a device driver, but I am not sure that these calls are sufficient. Thank you, Cate
Re: Remove Device Nodes
Hello Cate, You can remove a driver by unlinking the device node and closing all open references to the driver (provided that the driver properly implements the unlink method.) nsh> rm /dev/node is one way. Calling unlink() is another. What exactly are you willing to do? Could you please describe your use case? BR, Alan On 11/18/20, Ecaterina FEDORENCO wrote: > Hello all, > > I have a question regarding the device nodes from /dev folder. > > The sequence I execute is the following: > 1. smart_initialize method - creates /dev/smart1d file > > *mtd_part = mtd_partition(mtd, partoffset, (partsize >> 2) * 8); > smart_initialize(1, mtd_part, partname);* > > * mount("/dev/smart1d", "/mnt/smart", "smartfs", 0, NULL);* > 2. ftl_initialize and bchdev_register - create /dev/mtd1 and > /dev/mtdblock1 > > > > > > > *mtd_part2 = mtd_partition(mtd, partoffset, (partsize>>2)*8); > ftl_initialize(1, mtd_part2); snprintf(blockname, 32, > "/dev/mtdblock%d", 1); snprintf(charname, 32, "/dev/mtd%d", > 1); bchdev_register(blockname, charname, false);* > Is there a way to remove the device nodes(files) from /dev folder? > > For the second step I found *int bchdev_unregister(FAR const char > *chardev),* which removes only */dev/mtd1 *node. > For the first step, *unregister_driver() *can be called to remove a device > driver, but I am not sure that these calls are sufficient. > > Thank you, > Cate >
Re: Remove Device Nodes
Calling unlink() on a character driver should work just as Alan describes (provided that the character driver supports the unlink() method). In the specific case that you ask about about, the /dev/mtdblock1 driver is a block driver. The explanation is still correct, except that it is the block driver's unlink() method that is called. And it is the block driver that must self destruct when the unlink() method is called. The /dev/mtd1 is, I assume, a character driver that was instantiated via bchdev_register(). It should be unlinked first before the block driver. The bchdev_unlink() method will teardown the /dev/mtd1 instance when it can. Then the block driver can be unlinked. On 11/18/2020 2:38 PM, Alan Carvalho de Assis wrote: Hello Cate, You can remove a driver by unlinking the device node and closing all open references to the driver (provided that the driver properly implements the unlink method.) nsh> rm /dev/node is one way. Calling unlink() is another. What exactly are you willing to do? Could you please describe your use case? BR, Alan On 11/18/20, Ecaterina FEDORENCO wrote: Hello all, I have a question regarding the device nodes from /dev folder. The sequence I execute is the following: 1. smart_initialize method - creates /dev/smart1d file *mtd_part = mtd_partition(mtd, partoffset, (partsize >> 2) * 8); smart_initialize(1, mtd_part, partname);* * mount("/dev/smart1d", "/mnt/smart", "smartfs", 0, NULL);* 2. ftl_initialize and bchdev_register - create /dev/mtd1 and /dev/mtdblock1 *mtd_part2 = mtd_partition(mtd, partoffset, (partsize>>2)*8); ftl_initialize(1, mtd_part2); snprintf(blockname, 32, "/dev/mtdblock%d", 1); snprintf(charname, 32, "/dev/mtd%d", 1); bchdev_register(blockname, charname, false);* Is there a way to remove the device nodes(files) from /dev folder? For the second step I found *int bchdev_unregister(FAR const char *chardev),* which removes only */dev/mtd1 *node. For the first step, *unregister_driver() *can be called to remove a device driver, but I am not sure that these calls are sufficient. Thank you, Cate
Re: Remove Device Nodes
The /dev/mtd1 is, I assume, a character driver that was instantiated via bchdev_register(). It should be unlinked first before the block driver. The bchdev_unlink() method will teardown the /dev/mtd1 instance /*when it can*/. ... And it cannot do that until all of the open references to the driver are closed. If you do unlink while there are open references, the name will be removed from the file namespace, but the underlying driver instance will persist and will continue to hold resources until the last reference to the driver is closed. Then that underlying driver instance will be released.