summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-18 09:34:58 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-18 09:34:58 -0600
commitdbc81f57aa7088dd4d5e4414bd80b0b6656a8111 (patch)
treeb3387b5080d53813aa61b51b1b1524a036fed579
parentc875dcfd8a753cd131d39e1efa5f34642200e52c (diff)
downloadnuttx-dbc81f57aa7088dd4d5e4414bd80b0b6656a8111.tar.gz
nuttx-dbc81f57aa7088dd4d5e4414bd80b0b6656a8111.tar.bz2
nuttx-dbc81f57aa7088dd4d5e4414bd80b0b6656a8111.zip
VFS: The inode unlink method should not be support if operations on the root pseudo-filesystem are disabled.
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c2
-rw-r--r--nuttx/drivers/pipes/fifo.c2
-rw-r--r--nuttx/drivers/pipes/pipe.c2
-rw-r--r--nuttx/drivers/pipes/pipe_common.c4
-rw-r--r--nuttx/drivers/pipes/pipe_common.h2
-rw-r--r--nuttx/drivers/ramdisk.c25
-rw-r--r--nuttx/drivers/timers/rtc.c30
-rw-r--r--nuttx/include/nuttx/fs/fs.h4
-rw-r--r--nuttx/include/nuttx/rtc.h2
-rw-r--r--nuttx/net/local/Kconfig2
10 files changed, 73 insertions, 2 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
index c56970b0c..eb732b16e 100644
--- a/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
+++ b/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
@@ -121,7 +121,9 @@ static const struct rtc_ops_s g_rtc_ops =
#ifdef CONFIG_RTC_IOCTL
.ioctl = NULL,
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
.destroy = NULL,
+#endif
};
/* STM32 RTC device state */
diff --git a/nuttx/drivers/pipes/fifo.c b/nuttx/drivers/pipes/fifo.c
index 0c8f0d63f..7148edc3c 100644
--- a/nuttx/drivers/pipes/fifo.c
+++ b/nuttx/drivers/pipes/fifo.c
@@ -77,7 +77,9 @@ static const struct file_operations fifo_fops =
#ifndef CONFIG_DISABLE_POLL
pipecommon_poll, /* poll */
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
pipecommon_unlink /* unlink */
+#endif
};
/****************************************************************************
diff --git a/nuttx/drivers/pipes/pipe.c b/nuttx/drivers/pipes/pipe.c
index df29e3ed7..cec5d5f3d 100644
--- a/nuttx/drivers/pipes/pipe.c
+++ b/nuttx/drivers/pipes/pipe.c
@@ -86,7 +86,9 @@ static const struct file_operations pipe_fops =
#ifndef CONFIG_DISABLE_POLL
pipecommon_poll, /* poll */
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
pipecommon_unlink /* unlink */
+#endif
};
static sem_t g_pipesem = SEM_INITIALIZER(1);
diff --git a/nuttx/drivers/pipes/pipe_common.c b/nuttx/drivers/pipes/pipe_common.c
index d9ca1f226..026c11ab5 100644
--- a/nuttx/drivers/pipes/pipe_common.c
+++ b/nuttx/drivers/pipes/pipe_common.c
@@ -350,6 +350,7 @@ int pipecommon_close(FAR struct file *filep)
dev->d_refs = 0;
dev->d_nwriters = 0;
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
/* If, in addition, we have been unlinked, then also need to free the
* device structure as well to prevent a memory leak.
*/
@@ -359,6 +360,7 @@ int pipecommon_close(FAR struct file *filep)
pipecommon_freedev(dev);
return OK;
}
+#endif
}
sem_post(&dev->d_bfsem);
@@ -707,6 +709,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* Name: pipecommon_unlink
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
int pipecommon_unlink(FAR struct inode *inode)
{
FAR struct pipe_dev_s *dev;
@@ -736,5 +739,6 @@ int pipecommon_unlink(FAR struct inode *inode)
return OK;
}
+#endif
#endif /* CONFIG_DEV_PIPE_SIZE > 0 */
diff --git a/nuttx/drivers/pipes/pipe_common.h b/nuttx/drivers/pipes/pipe_common.h
index 2f1b11940..b9ef6e993 100644
--- a/nuttx/drivers/pipes/pipe_common.h
+++ b/nuttx/drivers/pipes/pipe_common.h
@@ -148,7 +148,9 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
int pipecommon_unlink(FAR struct inode *priv);
+#endif
#undef EXTERN
#ifdef __cplusplus
diff --git a/nuttx/drivers/ramdisk.c b/nuttx/drivers/ramdisk.c
index 2ccecc7c9..39fbc8d80 100644
--- a/nuttx/drivers/ramdisk.c
+++ b/nuttx/drivers/ramdisk.c
@@ -79,7 +79,9 @@ struct rd_struct_s
{
uint32_t rd_nsectors; /* Number of sectors on device */
uint16_t rd_sectsize; /* The size of one sector */
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
uint8_t rd_crefs; /* Open reference count */
+#endif
uint8_t rd_flags; /* See RDFLAG_* definitions */
#ifdef CONFIG_FS_WRITABLE
FAR uint8_t *rd_buffer; /* RAM disk backup memory */
@@ -92,10 +94,13 @@ struct rd_struct_s
* Private Function Prototypes
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static void rd_destroy(FAR struct rd_struct_s *dev);
static int rd_open(FAR struct inode *inode);
static int rd_close(FAR struct inode *inode);
+#endif
+
static ssize_t rd_read(FAR struct inode *inode, FAR unsigned char *buffer,
size_t start_sector, unsigned int nsectors);
#ifdef CONFIG_FS_WRITABLE
@@ -107,7 +112,10 @@ static int rd_geometry(FAR struct inode *inode,
FAR struct geometry *geometry);
static int rd_ioctl(FAR struct inode *inode, int cmd,
unsigned long arg);
+
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rd_unlink(FAR struct inode *inode);
+#endif
/****************************************************************************
* Private Data
@@ -115,8 +123,13 @@ static int rd_unlink(FAR struct inode *inode);
static const struct block_operations g_bops =
{
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
rd_open, /* open */
rd_close, /* close */
+#else
+ 0, /* open */
+ 0, /* close */
+#endif
rd_read, /* read */
#ifdef CONFIG_FS_WRITABLE
rd_write, /* write */
@@ -125,7 +138,9 @@ static const struct block_operations g_bops =
#endif
rd_geometry, /* geometry */
rd_ioctl, /* ioctl */
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
rd_unlink /* unlink */
+#endif
};
/****************************************************************************
@@ -140,6 +155,7 @@ static const struct block_operations g_bops =
*
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static void rd_destroy(FAR struct rd_struct_s *dev)
{
fvdbg("Destroying RAM disk\n");
@@ -159,6 +175,7 @@ static void rd_destroy(FAR struct rd_struct_s *dev)
kmm_free(dev);
}
+#endif
/****************************************************************************
* Name: rd_open
@@ -167,6 +184,7 @@ static void rd_destroy(FAR struct rd_struct_s *dev)
*
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rd_open(FAR struct inode *inode)
{
FAR struct rd_struct_s *dev;
@@ -182,6 +200,7 @@ static int rd_open(FAR struct inode *inode)
fvdbg("rd_crefs: %d\n", dev->rd_crefs);
return OK;
}
+#endif
/****************************************************************************
* Name: rd_close
@@ -190,6 +209,7 @@ static int rd_open(FAR struct inode *inode)
*
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rd_close(FAR struct inode *inode)
{
FAR struct rd_struct_s *dev;
@@ -203,6 +223,7 @@ static int rd_close(FAR struct inode *inode)
dev->rd_crefs--;
fvdbg("rd_crefs: %d\n", dev->rd_crefs);
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
/* Was that the last open reference to the RAM disk? */
if (dev->rd_crefs == 0)
@@ -216,9 +237,11 @@ static int rd_close(FAR struct inode *inode)
rd_destroy(dev);
}
}
+#endif
return OK;
}
+#endif
/****************************************************************************
* Name: rd_read
@@ -370,6 +393,7 @@ static int rd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
*
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rd_unlink(FAR struct inode *inode)
{
FAR struct rd_struct_s *dev;
@@ -392,6 +416,7 @@ static int rd_unlink(FAR struct inode *inode)
return OK;
}
+#endif
/****************************************************************************
* Public Functions
diff --git a/nuttx/drivers/timers/rtc.c b/nuttx/drivers/timers/rtc.c
index 6550131e4..68f7366af 100644
--- a/nuttx/drivers/timers/rtc.c
+++ b/nuttx/drivers/timers/rtc.c
@@ -56,8 +56,10 @@
struct rtc_upperhalf_s
{
FAR struct rtc_lowerhalf_s *lower; /* Contained lower half driver */
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
uint8_t crefs; /* Number of open references */
bool unlinked; /* True if the driver has been unlinked */
+#endif
};
/****************************************************************************
@@ -66,17 +68,25 @@ struct rtc_upperhalf_s
/* Internal logic */
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static void rtc_destroy(FAR struct rtc_upperhalf_s *upper);
+#endif
/* Character driver methods */
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rtc_open(FAR struct file *filep);
static int rtc_close(FAR struct file *filep);
+#endif
+
static ssize_t rtc_read(FAR struct file *filep, FAR char *, size_t);
static ssize_t rtc_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rtc_unlink(FAR struct inode *inode);
+#endif
/****************************************************************************
* Private Data
@@ -84,8 +94,13 @@ static int rtc_unlink(FAR struct inode *inode);
static const struct file_operations rtc_fops =
{
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
rtc_open, /* open */
rtc_close, /* close */
+#else
+ 0, /* open */
+ 0, /* close */
+#endif
rtc_read, /* read */
rtc_write, /* write */
0, /* seek */
@@ -93,7 +108,9 @@ static const struct file_operations rtc_fops =
#ifndef CONFIG_DISABLE_POLL
0, /* poll */
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
rtc_unlink /* unlink */
+#endif
};
/****************************************************************************
@@ -101,9 +118,10 @@ static const struct file_operations rtc_fops =
****************************************************************************/
/****************************************************************************
- * Name: rtc_read
+ * Name: rtc_destory
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static void rtc_destroy(FAR struct rtc_upperhalf_s *upper)
{
/* If the lower half driver provided a destroy method, then call that
@@ -121,11 +139,13 @@ static void rtc_destroy(FAR struct rtc_upperhalf_s *upper)
kmm_free(upper);
}
+#endif
/****************************************************************************
* Name: rtc_open
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rtc_open(FAR struct file *filep)
{
FAR struct inode *inode;
@@ -146,11 +166,13 @@ static int rtc_open(FAR struct file *filep)
DEBUGASSERT(upper->crefs > 0);
return OK;
}
+#endif
/****************************************************************************
* Name: rtc_close
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rtc_close(FAR struct file *filep)
{
FAR struct inode *inode;
@@ -181,6 +203,7 @@ static int rtc_close(FAR struct file *filep)
return OK;
}
+#endif
/****************************************************************************
* Name: rtc_read
@@ -526,6 +549,7 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* Name: rtc_unlink
****************************************************************************/
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int rtc_unlink(FAR struct inode *inode)
{
FAR struct rtc_upperhalf_s *upper;
@@ -552,6 +576,7 @@ static int rtc_unlink(FAR struct inode *inode)
return OK;
}
+#endif
/****************************************************************************
* Public Functions
@@ -593,8 +618,11 @@ int rtc_initialize(int minor, FAR struct rtc_lowerhalf_s *lower)
/* Initialize the upper half container */
upper->lower = lower; /* Contain lower half driver */
+
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
upper->crefs = 0; /* No open references */
upper->unlinked = false; /* Driver is not unlinked */
+#endif
/* Create the driver name. There is space for the a minor number up to 6
* characters
diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h
index 46daf7d3a..0b6a7d928 100644
--- a/nuttx/include/nuttx/fs/fs.h
+++ b/nuttx/include/nuttx/fs/fs.h
@@ -99,7 +99,9 @@ struct file_operations
#ifndef CONFIG_DISABLE_POLL
int (*poll)(FAR struct file *filep, struct pollfd *fds, bool setup);
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
int (*unlink)(FAR struct inode *inode);
+#endif
};
/* This structure provides information about the state of a block driver */
@@ -131,7 +133,9 @@ struct block_operations
size_t start_sector, unsigned int nsectors);
int (*geometry)(FAR struct inode *inode, FAR struct geometry *geometry);
int (*ioctl)(FAR struct inode *inode, int cmd, unsigned long arg);
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
int (*unlink)(FAR struct inode *inode);
+#endif
};
/* This structure is provided by a filesystem to describe a mount point.
diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/rtc.h
index ba8add61a..5f7b40778 100644
--- a/nuttx/include/nuttx/rtc.h
+++ b/nuttx/include/nuttx/rtc.h
@@ -423,11 +423,13 @@ struct rtc_ops_s
unsigned long arg);
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
/* The driver has been unlinked and there are no further open references
* to the driver.
*/
CODE int (*destroy)(FAR struct rtc_lowerhalf_s *lower);
+#endif
};
/* When the RTC driver is instantiated, a reference to struct
diff --git a/nuttx/net/local/Kconfig b/nuttx/net/local/Kconfig
index 6749ec7d2..88527c276 100644
--- a/nuttx/net/local/Kconfig
+++ b/nuttx/net/local/Kconfig
@@ -4,7 +4,7 @@
#
menu "Unix Domain Socket Support"
- depends on NET
+ depends on NET && !DISABLE_PSEUDOFS_OPERATIONS
config NET_LOCAL
bool "Unix domain (local) sockets"