Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189279
b: refs/heads/master
c: 89ae975
h: refs/heads/master
i:
  189277: 39899b2
  189275: f97ab40
  189271: c3af706
  189263: a4359b6
  189247: 7cc78d4
v: v3
  • Loading branch information
Michal Simek committed Apr 1, 2010
1 parent e472a4e commit d9ab327
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 57 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94804a9b3d0e62096a52fb62afcea32b899380c5
refs/heads/master: 89ae9753aef160c2f7bcecec21a7c4a6bc4c9b9b
88 changes: 32 additions & 56 deletions trunk/arch/microblaze/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,67 +294,16 @@ extern long __user_bad(void);

#define put_user(x, ptr) __put_user((x), (ptr))

static inline long strnlen_user(const char __user *src, long count)
{
return strlen(src) + 1;
}

#define __do_strncpy_from_user(dst, src, count, res) \
do { \
char *tmp; \
strncpy(dst, src, count); \
for (tmp = dst; *tmp && count > 0; tmp++, count--) \
; \
res = (tmp - dst); \
} while (0)

static inline long __strncpy_from_user(char *dst,
const char __user *src, long count)
{
long res;
__do_strncpy_from_user(dst, src, count, res);
return res;
}

static inline long strncpy_from_user(char *dst,
const char __user *src, long count)
{
long res = -EFAULT;
if (access_ok(VERIFY_READ, src, 1))
__do_strncpy_from_user(dst, src, count, res);
return res;
}

extern long strncpy_from_user(char *dst, const char *src, long count);
extern long strnlen_user(const char *src, long count);

#else /* CONFIG_MMU */

#define put_user(x, ptr) \
({ \
access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) \
? __put_user((x), (ptr)) : -EFAULT; \
})

extern int __strncpy_user(char *to, const char __user *from, int len);

#define __strncpy_from_user __strncpy_user

static inline long
strncpy_from_user(char *dst, const char __user *src, long count)
{
if (!access_ok(VERIFY_READ, src, 1))
return -EFAULT;
return __strncpy_from_user(dst, src, count);
}

extern int __strnlen_user(const char __user *sstr, int len);

#define strnlen_user(str, len) \
(access_ok(VERIFY_READ, str, 1) ? __strnlen_user(str, len) : 0)

#endif /* CONFIG_MMU */

/* copy_to_from_user */
#define __copy_from_user(to, from, n) \
__copy_tofrom_user((__force void __user *)(to), \
(void __user *)(from), (n))
Expand All @@ -367,8 +316,7 @@ static inline long copy_from_user(void *to,
might_sleep();
if (access_ok(VERIFY_READ, from, n))
return __copy_from_user(to, from, n);
else
return n;
return n;
}

#define __copy_to_user(to, from, n) \
Expand All @@ -382,8 +330,36 @@ static inline long copy_to_user(void __user *to,
might_sleep();
if (access_ok(VERIFY_WRITE, to, n))
return __copy_to_user(to, from, n);
else
return n;
return n;
}

/*
* Copy a null terminated string from userspace.
*/
extern int __strncpy_user(char *to, const char __user *from, int len);

#define __strncpy_from_user __strncpy_user

static inline long
strncpy_from_user(char *dst, const char __user *src, long count)
{
if (!access_ok(VERIFY_READ, src, 1))
return -EFAULT;
return __strncpy_from_user(dst, src, count);
}

/*
* Return the size of a string (including the ending 0)
*
* Return 0 on exception, a value greater than N if too long
*/
extern int __strnlen_user(const char __user *sstr, int len);

static inline long strnlen_user(const char __user *src, long n)
{
if (!access_ok(VERIFY_READ, src, 1))
return 0;
return __strnlen_user(src, n);
}

#endif /* __ASSEMBLY__ */
Expand Down

0 comments on commit d9ab327

Please sign in to comment.