Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xenomai
xenomai
Commits
c532d68f
Commit
c532d68f
authored
Sep 09, 2014
by
Philippe Gerum
Browse files
cobalt/posix/mq, lib/cobalt: alloc file descriptors on the anon inode
parent
291b25fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
kernel/cobalt/posix/mqueue.c
View file @
c532d68f
...
...
@@ -18,6 +18,8 @@
#include <stdarg.h>
#include <linux/fs.h>
#include <linux/fdtable.h>
#include <linux/anon_inodes.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <cobalt/kernel/select.h>
...
...
@@ -284,13 +286,11 @@ static inline int mqd_create(struct cobalt_mq *mq, unsigned long flags, int ufd)
return
rtdm_fd_enter
(
p
,
&
mqd
->
fd
,
ufd
,
COBALT_MQD_MAGIC
,
&
mqd_ops
);
}
static
int
mq_open
(
int
uqd
,
const
char
*
name
,
int
oflags
,
...)
static
int
mq_open
(
int
uqd
,
const
char
*
name
,
int
oflags
,
int
mode
,
struct
mq_attr
*
attr
)
{
struct
cobalt_mq
*
mq
;
struct
mq_attr
*
attr
;
xnhandle_t
handle
;
mode_t
mode
;
va_list
ap
;
spl_t
s
;
int
err
;
...
...
@@ -337,11 +337,6 @@ static int mq_open(int uqd, const char *name, int oflags, ...)
if
(
mq
==
NULL
)
return
-
ENOSPC
;
va_start
(
ap
,
oflags
);
mode
=
va_arg
(
ap
,
int
);
/* unused */
attr
=
va_arg
(
ap
,
struct
mq_attr
*
);
va_end
(
ap
);
err
=
mq_init
(
mq
,
attr
);
if
(
err
)
{
xnfree
(
mq
);
...
...
@@ -792,11 +787,14 @@ COBALT_SYSCALL(mq_notify, primary,
COBALT_SYSCALL
(
mq_open
,
lostage
,
int
,
(
const
char
__user
*
u_name
,
int
oflags
,
mode_t
mode
,
struct
mq_attr
__user
*
u_attr
,
mqd_t
uqd
))
mode_t
mode
,
struct
mq_attr
__user
*
u_attr
))
{
struct
mq_attr
locattr
,
*
attr
;
char
name
[
COBALT_MAXNAME
];
unsigned
len
;
struct
xnsys_ppd
*
ppd
;
unsigned
int
len
;
mqd_t
uqd
;
int
ret
;
len
=
__xn_safe_strncpy_from_user
(
name
,
u_name
,
sizeof
(
name
));
if
(
len
<
0
)
...
...
@@ -816,9 +814,20 @@ COBALT_SYSCALL(mq_open, lostage,
}
else
attr
=
NULL
;
trace_cobalt_mq_open
(
name
,
oflags
,
mode
,
uqd
);
trace_cobalt_mq_open
(
name
,
oflags
,
mode
);
ppd
=
cobalt_ppd_get
(
0
);
uqd
=
anon_inode_getfd
(
"[cobalt-mq]"
,
&
rtdm_dumb_fops
,
ppd
,
oflags
);
if
(
uqd
<
0
)
return
uqd
;
ret
=
mq_open
(
uqd
,
name
,
oflags
,
mode
,
attr
);
if
(
ret
<
0
)
{
__close_fd
(
current
->
files
,
uqd
);
return
ret
;
}
return
mq_open
(
uqd
,
name
,
oflags
,
mode
,
attr
)
;
return
uqd
;
}
COBALT_SYSCALL
(
mq_close
,
lostage
,
int
,
(
mqd_t
uqd
))
...
...
kernel/cobalt/posix/mqueue.h
View file @
c532d68f
...
...
@@ -32,8 +32,7 @@ struct mq_attr {
COBALT_SYSCALL_DECL
(
mq_open
,
int
,
(
const
char
__user
*
u_name
,
int
oflags
,
mode_t
mode
,
struct
mq_attr
__user
*
u_attr
,
mqd_t
uqd
));
mode_t
mode
,
struct
mq_attr
__user
*
u_attr
));
COBALT_SYSCALL_DECL
(
mq_close
,
int
,
(
mqd_t
uqd
));
...
...
kernel/cobalt/trace/cobalt-posix.h
View file @
c532d68f
...
...
@@ -739,28 +739,25 @@ TRACE_EVENT(cobalt_cond_wait,
);
TRACE_EVENT
(
cobalt_mq_open
,
TP_PROTO
(
const
char
*
name
,
int
oflags
,
mode_t
mode
,
mqd_t
mqd
),
TP_ARGS
(
name
,
oflags
,
mode
,
mqd
),
TP_PROTO
(
const
char
*
name
,
int
oflags
,
mode_t
mode
),
TP_ARGS
(
name
,
oflags
,
mode
),
TP_STRUCT__entry
(
__string
(
name
,
name
)
__field
(
int
,
oflags
)
__field
(
mode_t
,
mode
)
__field
(
mqd_t
,
mqd
)
),
TP_fast_assign
(
__assign_str
(
name
,
name
);
__entry
->
oflags
=
oflags
;
__entry
->
mode
=
(
oflags
&
O_CREAT
)
?
mode
:
0
;
__entry
->
mqd
=
mqd
;
),
TP_printk
(
"name=%s oflags=%#x(%s) mode=%o
mqd=%d
"
,
TP_printk
(
"name=%s oflags=%#x(%s) mode=%o"
,
__get_str
(
name
),
__entry
->
oflags
,
cobalt_print_oflags
(
__entry
->
oflags
),
__entry
->
mode
,
__entry
->
mqd
)
__entry
->
mode
)
);
TRACE_EVENT
(
cobalt_mq_notify
,
...
...
lib/cobalt/mq.c
View file @
c532d68f
...
...
@@ -104,7 +104,7 @@ COBALT_IMPL(mqd_t, mq_open, (const char *name, int oflags, ...))
struct
mq_attr
*
attr
=
NULL
;
mode_t
mode
=
0
;
va_list
ap
;
int
q
,
err
;
int
fd
;
if
((
oflags
&
O_CREAT
)
!=
0
)
{
va_start
(
ap
,
oflags
);
...
...
@@ -113,17 +113,13 @@ COBALT_IMPL(mqd_t, mq_open, (const char *name, int oflags, ...))
va_end
(
ap
);
}
q
=
__STD
(
open
(
"/dev/null"
,
O_RDWR
,
0
));
if
(
q
==
-
1
)
return
(
mqd_t
)
-
1
;
err
=
-
XENOMAI_SYSCALL5
(
sc_cobalt_mq_open
,
name
,
oflags
,
mode
,
attr
,
q
);
if
(
!
err
)
return
(
mqd_t
)
q
;
fd
=
XENOMAI_SYSCALL4
(
sc_cobalt_mq_open
,
name
,
oflags
,
mode
,
attr
);
if
(
fd
<
0
)
{
errno
=
-
fd
;
return
(
mqd_t
)
-
1
;
}
errno
=
err
;
return
(
mqd_t
)
-
1
;
return
(
mqd_t
)
fd
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment