Module: xenomai-rpm
Branch: queue/vfile
Commit: 9ca824691013e72c05e0ec53e3dcf5c9abc65f77
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=9ca824691013e72c05e0ec53e3dcf5c9abc65f77

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Apr 30 10:40:35 2010 +0200

nucleus/vfile: rename xnvfile_read_input -> xnvfile_get_blob

This interface should be used to retrieve the data sent by userland
from the ->store() vfile method, which is actually triggered by a
write() in vfs parlance. Use get instead of read to avoid logic
clashes.

Since a few specialized helpers should be added in the future to fetch
type-specific data (such as strings, or ints), use "blob" for this
untyped one.

---

 include/nucleus/vfile.h |    4 ++--
 ksrc/nucleus/vfile.c    |   18 ++++++++++--------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/include/nucleus/vfile.h b/include/nucleus/vfile.h
index a40bc10..ad650e2 100644
--- a/include/nucleus/vfile.h
+++ b/include/nucleus/vfile.h
@@ -149,8 +149,8 @@ int xnvfile_init_link(const char *from,
 
 void xnvfile_destroy_link(struct xnvfile_link *vlink);
 
-ssize_t xnvfile_read_input(struct xnvfile_input *input,
-                          void *data, size_t size);
+ssize_t xnvfile_get_blob(struct xnvfile_input *input,
+                        void *data, size_t size);
 
 #ifdef __cplusplus
 }
diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index 90cbf55..a218fe7 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -350,16 +350,18 @@ void xnvfile_destroy_link(struct xnvfile_link *vlink)
 }
 EXPORT_SYMBOL_GPL(xnvfile_destroy_link);
 
-ssize_t xnvfile_read_input(struct xnvfile_input *input,
-                          void *data, size_t size)
+ssize_t xnvfile_get_blob(struct xnvfile_input *input,
+                        void *data, size_t size)
 {
-       if (input->size < size)
-               size = input->size;
+       ssize_t nbytes = input->size;
 
-       if (size > 0 &&
-           __xn_safe_copy_from_user(data, input->u_buf, size))
+       if (nbytes < size)
+               nbytes = size;
+
+       if (nbytes > 0 &&
+           __xn_safe_copy_from_user(data, input->u_buf, nbytes))
                return -EFAULT;
 
-       return size;
+       return nbytes;
 }
-EXPORT_SYMBOL_GPL(xnvfile_read_input);
+EXPORT_SYMBOL_GPL(xnvfile_get_blob);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to