[11/30] virtiofsd: fuse: Make iov_length usable outside fuse_lowlevel.c
diff mbox series

Message ID 20191021105832.36574-12-dgilbert@redhat.com
State New
Headers show
Series
  • virtiofs daemon (base)
Related show

Commit Message

Dr. David Alan Gilbert Oct. 21, 2019, 10:58 a.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 contrib/virtiofsd/fuse_lowlevel.c | 2 +-
 contrib/virtiofsd/fuse_lowlevel.h | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

Comments

Marc-André Lureau Oct. 21, 2019, 2:47 p.m. UTC | #1
Hi

On Mon, Oct 21, 2019 at 1:24 PM Dr. David Alan Gilbert (git)
<dgilbert@redhat.com> wrote:
>
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Similar function already exists in util/iov.c, iov_size()

Perhaps you could link with util/iov.o and others to avoid code duplication.


> ---
>  contrib/virtiofsd/fuse_lowlevel.c | 2 +-
>  contrib/virtiofsd/fuse_lowlevel.h | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c
> index 5ea113ab49..ff68ec0c9d 100644
> --- a/contrib/virtiofsd/fuse_lowlevel.c
> +++ b/contrib/virtiofsd/fuse_lowlevel.c
> @@ -74,7 +74,7 @@ static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
>         ST_CTIM_NSEC_SET(stbuf, attr->ctimensec);
>  }
>
> -static size_t iov_length(const struct iovec *iov, size_t count)
> +size_t iov_length(const struct iovec *iov, size_t count)
>  {
>         size_t seg;
>         size_t ret = 0;
> diff --git a/contrib/virtiofsd/fuse_lowlevel.h b/contrib/virtiofsd/fuse_lowlevel.h
> index 018e7c0be0..84379a4761 100644
> --- a/contrib/virtiofsd/fuse_lowlevel.h
> +++ b/contrib/virtiofsd/fuse_lowlevel.h
> @@ -2000,6 +2000,15 @@ void fuse_session_process_buf(struct fuse_session *se,
>   */
>  int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf);
>
> +/**
> + * General utility to get the length of an iov, not Fuse specific
> + *
> + * @param iov The iovec to get the length of
> + * @param count Number of entries in the iovec
> + * @return the total length of iov in bytes
> + */
> +size_t iov_length(const struct iovec *iov, size_t count);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> --
> 2.23.0
>
>
Dr. David Alan Gilbert Oct. 22, 2019, 10:01 a.m. UTC | #2
* Marc-André Lureau (marcandre.lureau@gmail.com) wrote:
> Hi
> 
> On Mon, Oct 21, 2019 at 1:24 PM Dr. David Alan Gilbert (git)
> <dgilbert@redhat.com> wrote:
> >
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> Similar function already exists in util/iov.c, iov_size()
> 
> Perhaps you could link with util/iov.o and others to avoid code duplication.

Done.
(It's a shame there's no iov_* functions in glib; every project
reinvents iov_ functions).

Dave

> 
> > ---
> >  contrib/virtiofsd/fuse_lowlevel.c | 2 +-
> >  contrib/virtiofsd/fuse_lowlevel.h | 9 +++++++++
> >  2 files changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c
> > index 5ea113ab49..ff68ec0c9d 100644
> > --- a/contrib/virtiofsd/fuse_lowlevel.c
> > +++ b/contrib/virtiofsd/fuse_lowlevel.c
> > @@ -74,7 +74,7 @@ static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
> >         ST_CTIM_NSEC_SET(stbuf, attr->ctimensec);
> >  }
> >
> > -static size_t iov_length(const struct iovec *iov, size_t count)
> > +size_t iov_length(const struct iovec *iov, size_t count)
> >  {
> >         size_t seg;
> >         size_t ret = 0;
> > diff --git a/contrib/virtiofsd/fuse_lowlevel.h b/contrib/virtiofsd/fuse_lowlevel.h
> > index 018e7c0be0..84379a4761 100644
> > --- a/contrib/virtiofsd/fuse_lowlevel.h
> > +++ b/contrib/virtiofsd/fuse_lowlevel.h
> > @@ -2000,6 +2000,15 @@ void fuse_session_process_buf(struct fuse_session *se,
> >   */
> >  int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf);
> >
> > +/**
> > + * General utility to get the length of an iov, not Fuse specific
> > + *
> > + * @param iov The iovec to get the length of
> > + * @param count Number of entries in the iovec
> > + * @return the total length of iov in bytes
> > + */
> > +size_t iov_length(const struct iovec *iov, size_t count);
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > --
> > 2.23.0
> >
> >
> 
> 
> -- 
> Marc-André Lureau
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Patch
diff mbox series

diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c
index 5ea113ab49..ff68ec0c9d 100644
--- a/contrib/virtiofsd/fuse_lowlevel.c
+++ b/contrib/virtiofsd/fuse_lowlevel.c
@@ -74,7 +74,7 @@  static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
 	ST_CTIM_NSEC_SET(stbuf, attr->ctimensec);
 }
 
-static	size_t iov_length(const struct iovec *iov, size_t count)
+size_t iov_length(const struct iovec *iov, size_t count)
 {
 	size_t seg;
 	size_t ret = 0;
diff --git a/contrib/virtiofsd/fuse_lowlevel.h b/contrib/virtiofsd/fuse_lowlevel.h
index 018e7c0be0..84379a4761 100644
--- a/contrib/virtiofsd/fuse_lowlevel.h
+++ b/contrib/virtiofsd/fuse_lowlevel.h
@@ -2000,6 +2000,15 @@  void fuse_session_process_buf(struct fuse_session *se,
  */
 int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf);
 
+/**
+ * General utility to get the length of an iov, not Fuse specific
+ *
+ * @param iov The iovec to get the length of
+ * @param count Number of entries in the iovec
+ * @return the total length of iov in bytes
+ */
+size_t iov_length(const struct iovec *iov, size_t count);
+
 #ifdef __cplusplus
 }
 #endif