Merge branch 'upstream-fixes' into upstream
[pandora-kernel.git] / fs / 9p / conv.c
index 32a9f99..56d88c1 100644 (file)
@@ -8,9 +8,8 @@
  *  Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  *
  *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+ *  it under the terms of the GNU General Public License version 2
+ *  as published by the Free Software Foundation.
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,7 +24,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
@@ -116,13 +114,19 @@ static void buf_put_int64(struct cbuf *buf, u64 val)
        }
 }
 
-static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
+static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
 {
+       char *ret;
+
+       ret = NULL;
        if (buf_check_size(buf, slen + 2)) {
                buf_put_int16(buf, slen);
+               ret = buf->p;
                memcpy(buf->p, s, slen);
                buf->p += slen;
        }
+
+       return ret;
 }
 
 static inline void buf_put_string(struct cbuf *buf, const char *s)
@@ -430,15 +434,19 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p)
 static void
 v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
 {
-       if (data) {
-               str->len = strlen(data);
-               str->str = bufp->p;
-       } else {
-               str->len = 0;
-               str->str = NULL;
-       }
+       int len;
+       char *s;
 
-       buf_put_stringn(bufp, data, str->len);
+       if (data)
+               len = strlen(data);
+       else
+               len = 0;
+
+       s = buf_put_stringn(bufp, data, len);
+       if (str) {
+               str->len = len;
+               str->str = s;
+       }
 }
 
 static int
@@ -526,6 +534,7 @@ struct v9fs_fcall *v9fs_create_tversion(u32 msize, char *version)
        return fc;
 }
 
+#if 0
 struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname)
 {
        int size;
@@ -549,6 +558,7 @@ struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname)
       error:
        return fc;
 }
+#endif  /*  0  */
 
 struct v9fs_fcall *
 v9fs_create_tattach(u32 fid, u32 afid, char *uname, char *aname)
@@ -654,7 +664,8 @@ struct v9fs_fcall *v9fs_create_topen(u32 fid, u8 mode)
        return fc;
 }
 
-struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
+struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
+       char *extension, int extended)
 {
        int size;
        struct v9fs_fcall *fc;
@@ -662,6 +673,11 @@ struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
        struct cbuf *bufp = &buffer;
 
        size = 4 + 2 + strlen(name) + 4 + 1;    /* fid[4] name[s] perm[4] mode[1] */
+       if (extended) {
+               size += 2 +                     /* extension[s] */
+                   (extension == NULL ? 0 : strlen(extension));
+       }
+
        fc = v9fs_create_common(bufp, size, TCREATE);
        if (IS_ERR(fc))
                goto error;
@@ -670,6 +686,8 @@ struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
        v9fs_put_str(bufp, name, &fc->params.tcreate.name);
        v9fs_put_int32(bufp, perm, &fc->params.tcreate.perm);
        v9fs_put_int8(bufp, mode, &fc->params.tcreate.mode);
+       if (extended)
+               v9fs_put_str(bufp, extension, &fc->params.tcreate.extension);
 
        if (buf_check_overflow(bufp)) {
                kfree(fc);