xiaoxiang781216 commented on a change in pull request #2631:
URL: https://github.com/apache/incubator-nuttx/pull/2631#discussion_r551001295
##########
File path: fs/mqueue/mq_open.c
##########
@@ -235,6 +262,115 @@ int nxmq_open(FAR const char *mq_name, int oflags, mode_t
mode,
return ret;
}
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: file_mq_open
+ *
+ * Description:
+ * This function establish a connection between a named message queue and
+ * the calling task. This is an internal OS interface. It is functionally
+ * equivalent to mq_open() except that:
+ *
+ * - It is not a cancellation point, and
+ * - It does not modify the errno value.
+ *
+ * See comments with mq_open() for a more complete description of the
+ * behavior of this function
+ *
+ * Input Parameters:
+ * mq_name - Name of the queue to open
+ * oflags - open flags
+ * Optional parameters. When the O_CREAT flag is specified, two optional
+ * parameters are expected:
+ *
+ * 1. mode_t mode (ignored), and
+ * 2. struct mq_attr *attr. The mq_maxmsg attribute
+ * is used at the time that the message queue is
+ * created to determine the maximum number of
+ * messages that may be placed in the message queue.
+ *
+ * Returned Value:
+ * This is an internal OS interface and should not be used by applications.
+ * It follows the NuttX internal error return policy: Zero (OK) is
+ * returned on success, mqdes point to the new message queue descriptor.
+ * A negated errno value is returned on failure.
+ *
+ ****************************************************************************/
+
+int file_mq_open(FAR struct file *mq,
+ FAR const char *mq_name, int oflags, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, oflags);
+ ret = file_mq_vopen(mq, mq_name, oflags, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: nxmq_open
+ *
+ * Description:
+ * This function establish a connection between a named message queue and
+ * the calling task. This is an internal OS interface. It is functionally
+ * equivalent to mq_open() except that:
+ *
+ * - It is not a cancellation point, and
+ * - It does not modify the errno value.
+ *
+ * See comments with mq_open() for a more complete description of the
+ * behavior of this function
+ *
+ * Input Parameters:
+ * mq_name - Name of the queue to open
+ * oflags - open flags
+ * Optional parameters. When the O_CREAT flag is specified, two optional
+ * parameters are expected:
+ *
+ * 1. mode_t mode (ignored), and
+ * 2. struct mq_attr *attr. The mq_maxmsg attribute
+ * is used at the time that the message queue is
+ * created to determine the maximum number of
+ * messages that may be placed in the message queue.
+ *
+ * Returned Value:
+ * This is an internal OS interface and should not be used by applications.
+ * It follows the NuttX internal error return policy: Zero (OK) is
+ * returned on success, mqdes point to the new message queue descriptor.
+ * A negated errno value is returned on failure.
+ *
+ ****************************************************************************/
+
+int nxmq_open(FAR mqd_t *mqdes, FAR const char *mq_name, int oflags, ...)
+{
+ struct file mq;
+ va_list ap;
+ int ret;
+
+ va_start(ap, oflags);
+ ret = file_mq_vopen(&mq, mq_name, oflags, ap);
+ va_end(ap);
+ if (ret < 0)
+ {
+ return ret;
+ }
+
+ *mqdes = files_allocate(mq.f_inode, mq.f_oflags, 0, 0);
Review comment:
change the first 0 to mq.f_priv
##########
File path: fs/mqueue/mq_unlink.c
##########
@@ -62,97 +62,43 @@
*
****************************************************************************/
-int nxmq_unlink(FAR const char *mq_name)
+int file_mq_unlink(FAR const char *mq_name)
Review comment:
don't need
##########
File path: fs/mqueue/mq_open.c
##########
@@ -266,31 +402,26 @@ int nxmq_open(FAR const char *mq_name, int oflags, mode_t
mode,
mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
{
- FAR struct mq_attr *attr = NULL;
- mode_t mode = 0;
+ struct file mq;
mqd_t mqdes;
va_list ap;
int ret;
- /* Were we asked to create it? */
-
- if ((oflags & O_CREAT) != 0)
+ va_start(ap, oflags);
+ ret = file_mq_vopen(&mq, mq_name, oflags, ap);
+ va_end(ap);
+ if (ret < 0)
{
- /* We have to extract the additional
- * parameters from the variable argument list.
- */
-
- va_start(ap, oflags);
- mode = va_arg(ap, mode_t);
- attr = va_arg(ap, FAR struct mq_attr *);
- va_end(ap);
+ set_errno(-ret);
+ return ERROR;
}
- ret = nxmq_open(mq_name, oflags, mode, attr, &mqdes);
- if (ret < 0)
+ mqdes = files_allocate(mq.f_inode, mq.f_oflags, 0, 0);
Review comment:
change the first 0 to mq.f_priv
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]