aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/conv.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/9p/conv.c')
-rw-r--r--fs/9p/conv.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/fs/9p/conv.c b/fs/9p/conv.c
index f62434d435b3..55ccfa10ee9e 100644
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -45,37 +45,6 @@ struct cbuf {
45 unsigned char *ep; 45 unsigned char *ep;
46}; 46};
47 47
48char *v9fs_str_copy(char *buf, int buflen, struct v9fs_str *str)
49{
50 int n;
51
52 if (buflen < str->len)
53 n = buflen;
54 else
55 n = str->len;
56
57 memmove(buf, str->str, n - 1);
58
59 return buf;
60}
61
62int v9fs_str_compare(char *buf, struct v9fs_str *str)
63{
64 int n, ret;
65
66 ret = strncmp(buf, str->str, str->len);
67
68 if (!ret) {
69 n = strlen(buf);
70 if (n < str->len)
71 ret = -1;
72 else if (n > str->len)
73 ret = 1;
74 }
75
76 return ret;
77}
78
79static inline void buf_init(struct cbuf *buf, void *data, int datalen) 48static inline void buf_init(struct cbuf *buf, void *data, int datalen)
80{ 49{
81 buf->sp = buf->p = data; 50 buf->sp = buf->p = data;
@@ -89,11 +58,14 @@ static inline int buf_check_overflow(struct cbuf *buf)
89 58
90static inline int buf_check_size(struct cbuf *buf, int len) 59static inline int buf_check_size(struct cbuf *buf, int len)
91{ 60{
92 if (buf->p + len > buf->ep && buf->p < buf->ep) { 61 if (buf->p + len > buf->ep) {
93 eprintk(KERN_ERR, "buffer overflow: want %d has %d\n", 62 if (buf->p < buf->ep) {
94 len, (int)(buf->ep - buf->p)); 63 eprintk(KERN_ERR, "buffer overflow: want %d has %d\n",
95 dump_stack(); 64 len, (int)(buf->ep - buf->p));
96 buf->p = buf->ep + 1; 65 dump_stack();
66 buf->p = buf->ep + 1;
67 }
68
97 return 0; 69 return 0;
98 } 70 }
99 71
@@ -527,6 +499,7 @@ v9fs_create_common(struct cbuf *bufp, u32 size, u8 id)
527 499
528void v9fs_set_tag(struct v9fs_fcall *fc, u16 tag) 500void v9fs_set_tag(struct v9fs_fcall *fc, u16 tag)
529{ 501{
502 fc->tag = tag;
530 *(__le16 *) (fc->sdata + 5) = cpu_to_le16(tag); 503 *(__le16 *) (fc->sdata + 5) = cpu_to_le16(tag);
531} 504}
532 505