📄 unamei.c
字号:
/* * unamei.c * * Copyright (C) 2006 Insigme Co., Ltd * * Authors: * - Lixing Chu * * This software has been developed while working on the Linux Unified Kernel * project (http://linux.insigma.com.cn) in the Insigma Reaserch Institute, * which is a subdivision of Insigma Co., Ltd (http://www.insigma.com.cn). * * The project is sponsored by Insigma Co., Ltd. * * The authors can be reached at linux@insigma.com.cn. * * 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. * * Revision History: * Jan 2006 - Created. */ /* * unamei.c: extend namei.c for wchar * Reference to Linux kernel code */#include <linux/module.h>#include <linux/fs.h>#include <linux/nls.h>#include <asm/uaccess.h>#include "win32.h"#include <linux/module.h>#ifdef CONFIG_UNIFIED_KERNELextern long wstrncpy_from_user(wchar_t *, const wchar_t *, long);extern void putwname(const wchar_t *);static inline int do_getwname(const wchar_t __user *wname, wchar_t *page){ int retval; unsigned long len = PATH_MAX; if (!segment_eq(get_fs(), KERNEL_DS)) { if ((unsigned long) wname >= TASK_SIZE) return -EFAULT; if (TASK_SIZE - (unsigned long) wname < PATH_MAX) len = TASK_SIZE - (unsigned long) wname; } retval = wstrncpy_from_user(page, wname, len); if (retval > 0) { if (retval < len) return 0; return -ENAMETOOLONG; } else if (!retval) retval = -ENOENT; return retval;} /* end do_getwname() */wchar_t *getwname(const wchar_t __user *wname){ wchar_t *tmp, *result; result = ERR_PTR(-ENOMEM); tmp = __getname(); if (tmp) { int retval = do_getwname(wname, tmp); result = tmp; if (retval < 0) { putwname(tmp); result = ERR_PTR(retval); } } return result;} /* end getwname() */void putwname(const wchar_t *wname){ __putname(wname);} /* end putwname */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -