brektrou 6 years ago committed by GitHub
parent e3f553f384
commit aad4790e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2213,18 +2213,18 @@ static int isFileReadable(const char *path, u32 *sz)
{
struct file *fp;
int ret = 0;
#ifdef set_fs
mm_segment_t oldfs;
#endif
char buf;
fp = filp_open(path, O_RDONLY, 0);
if (IS_ERR(fp))
ret = PTR_ERR(fp);
else {
#ifdef set_fs
oldfs = get_fs();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
set_fs(KERNEL_DS);
#else
set_fs(get_ds());
#endif
if (1 != readFile(fp, &buf, 1))
@ -2238,7 +2238,9 @@ static int isFileReadable(const char *path, u32 *sz)
#endif
}
#ifdef set_fs
set_fs(oldfs);
#endif
filp_close(fp, NULL);
}
return ret;
@ -2254,7 +2256,9 @@ static int isFileReadable(const char *path, u32 *sz)
static int retriveFromFile(const char *path, u8 *buf, u32 sz)
{
int ret = -1;
#ifdef set_fs
mm_segment_t oldfs;
#endif
struct file *fp;
if (path && buf) {
@ -2262,14 +2266,14 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#ifdef set_fs
oldfs = get_fs();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
set_fs(KERNEL_DS);
#else
set_fs(get_ds());
#endif
ret = readFile(fp, buf, sz);
set_fs(oldfs);
#else
ret = readFile(fp, buf, sz);
#endif
closeFile(fp);
RTW_INFO("%s readFile, ret:%d\n", __FUNCTION__, ret);
@ -2293,7 +2297,9 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
static int storeToFile(const char *path, u8 *buf, u32 sz)
{
int ret = 0;
#ifdef set_fs
mm_segment_t oldfs;
#endif
struct file *fp;
if (path && buf) {
@ -2301,14 +2307,14 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#ifdef set_fs
oldfs = get_fs();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
set_fs(KERNEL_DS);
#else
set_fs(get_ds());
#endif
ret = writeFile(fp, buf, sz);
set_fs(oldfs);
#else
ret = writeFile(fp, buf, sz);
#endif
closeFile(fp);
RTW_INFO("%s writeFile, ret:%d\n", __FUNCTION__, ret);

Loading…
Cancel
Save