summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r--freebsd/sys/sys/file.h25
-rw-r--r--freebsd/sys/sys/filedesc.h24
2 files changed, 26 insertions, 23 deletions
diff --git a/freebsd/sys/sys/file.h b/freebsd/sys/sys/file.h
index c52dc7a9..18274d67 100644
--- a/freebsd/sys/sys/file.h
+++ b/freebsd/sys/sys/file.h
@@ -330,11 +330,11 @@ struct file *rtems_bsd_get_file(int fd);
static inline int
rtems_bsd_do_fget(int fd, struct file **fpp)
{
- struct file *fp = rtems_bsd_get_file(fd);
+ struct file *fp;
+ fp = rtems_bsd_get_file(fd);
*fpp = fp;
-
- return fp != NULL ? 0 : EBADF;
+ return (fp != NULL ? 0 : EBADF);
}
#define fget(td, fd, rights, fpp) rtems_bsd_do_fget(fd, fpp)
@@ -374,14 +374,12 @@ static inline void
finit(struct file *fp, u_int fflag, short type, void *data,
const rtems_filesystem_file_handlers_r *ops)
{
- rtems_filesystem_location_info_t *pathinfo = &fp->f_io.pathinfo;
-
- (void) type;
+ (void)type;
fp->f_data = data;
- fp->f_io.flags |= rtems_bsd_fflag_to_libio_flags(fflag);
-
- pathinfo->handlers = ops;
+ fp->f_io.pathinfo.handlers = ops;
+ rtems_libio_iop_flags_set(&fp->f_io, LIBIO_FLAGS_OPEN |
+ rtems_bsd_fflag_to_libio_flags(fflag));
}
#endif /* __rtems__ */
int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp,
@@ -408,7 +406,14 @@ _fnoop(void)
#define fdrop(fp, td) \
(refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop())
#else /* __rtems__ */
-#define fdrop(fp, td) do { } while (0)
+static inline void
+rtems_bsd_fdrop(struct file *fp)
+{
+
+ rtems_libio_iop_drop(&fp->f_io);
+}
+
+#define fdrop(fp, td) rtems_bsd_fdrop(fp)
#endif /* __rtems__ */
#ifndef __rtems__
diff --git a/freebsd/sys/sys/filedesc.h b/freebsd/sys/sys/filedesc.h
index 579e5213..b1c3e24b 100644
--- a/freebsd/sys/sys/filedesc.h
+++ b/freebsd/sys/sys/filedesc.h
@@ -192,19 +192,20 @@ static inline int
falloc_caps(struct thread *td, struct file **resultfp, int *resultfd,
int flags, struct filecaps *fcaps)
{
- rtems_libio_t *iop = rtems_libio_allocate();
+ rtems_libio_t *iop;
- (void) td;
- (void) flags;
- (void) fcaps;
+ (void)td;
+ (void)flags;
+ (void)fcaps;
+ iop = rtems_libio_allocate();
*resultfp = rtems_bsd_iop_to_fp(iop);
if (iop != NULL) {
+ rtems_libio_iop_hold(iop);
iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
*resultfd = rtems_libio_iop_to_descriptor(iop);
-
return (0);
} else {
return (ENFILE);
@@ -263,17 +264,14 @@ static inline int
fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
struct file **fpp, seq_t *seqp)
{
+ struct file *fp;
+
(void)fdp;
(void)needrightsp;
(void)seqp;
-
- *fpp = rtems_bsd_get_file(fd);
-
- if (*fpp != NULL) {
- return (0);
- } else {
- return (EBADF);
- }
+ fp = rtems_bsd_get_file(fd);
+ *fpp = fp;
+ return (fp != NULL ? 0 : EBADF);
}
#endif /* __rtems__ */