lkml.org 
[lkml]   [2010]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC v2 PATCH 1/3] init: add sys-wrapper.h
Date
On Sunday 29 August 2010, Namhyung Kim wrote:
> +
> +/* These macro are called just before/after actual syscalls. */
> +#define KSYS_PREPARE \
> + mm_segment_t old_fs = get_fs(); \
> + set_fs(KERNEL_DS);
> +
> +#define KSYS_RESTORE \
> + set_fs(old_fs);

These macros are not that nice, because they depend on context.
I would probably open-code them in each function, or possibly
use a single macro to combine it to something like

#define kern_sys_call(call, ...) \
({ \
mm_segment_t old_fs = get_fs(); \
long result; \
set_fs(KERNEL_DS); \
result = call(__VA_ARGS__); \
set_fs(old_fs); \
result; \
})
static inline int kern_sys_link(const char *oldname, const char *newname)
{
return kern_sys_call(sys_link, (const char __user __force *)oldname,
(const char __user __force *)newname);
}
> +static inline int kern_sys_fchown(unsigned int fd, uid_t user, gid_t group)
> +{
> + int ret;
> + KSYS_PREPARE;
> +
> + ret = sys_fchown(fd, user, group);
> +
> + KSYS_RESTORE;
> + return ret;
> +}

When there are no pointer arguments, there is no need to do set_fs
tricks.

Arnd


\
 
 \ /
  Last update: 2010-08-30 14:15    [from the cache]
©2003-2011 Jasper Spaans