Skip to content
Snippets Groups Projects
Commit b654b627 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

migrate to linux 4.19, without ANY backward consideration

parent dded6419
No related branches found
No related tags found
No related merge requests found
#include "khellofs.h"
int hellofs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
#error fs api changed in linux 3.11.0. Please use a better kernel to build my code!
#endif
int hellofs_iterate(struct file *filp, struct dir_context *ctx) {
loff_t pos;
struct inode *inode;
struct super_block *sb;
......@@ -9,8 +13,8 @@ int hellofs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
struct hellofs_dir_record *dir_record;
uint64_t i;
pos = filp->f_pos;
inode = filp->f_dentry->d_inode;
pos = ctx->pos;
inode = filp->f_path.dentry->d_inode;
sb = inode->i_sb;
hellofs_inode = HELLOFS_INODE(inode);
......@@ -25,7 +29,7 @@ int hellofs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
printk(KERN_ERR
"Inode %llu of dentry %s is not a directory\n",
hellofs_inode->inode_no,
filp->f_dentry->d_name.name);
filp->f_path.dentry->d_name.name);
return -ENOTDIR;
}
......@@ -34,9 +38,8 @@ int hellofs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
dir_record = (struct hellofs_dir_record *)bh->b_data;
for (i = 0; i < hellofs_inode->dir_children_count; i++) {
filldir(dirent, dir_record->filename, HELLOFS_FILENAME_MAXLEN, pos,
dir_record->inode_no, DT_UNKNOWN);
filp->f_pos += sizeof(struct hellofs_dir_record);
dir_emit(ctx, dir_record->filename, HELLOFS_FILENAME_MAXLEN, dir_record->inode_no, DT_UNKNOWN);
ctx->pos += sizeof(struct hellofs_dir_record);
pos += sizeof(struct hellofs_dir_record);
dir_record++;
}
......
......@@ -58,10 +58,11 @@ ssize_t hellofs_write(struct file *filp, const char __user *buf, size_t len,
hellofs_inode = HELLOFS_INODE(inode);
hellofs_sb = HELLOFS_SB(sb);
ret = generic_write_checks(filp, ppos, &len, 0);
if (ret) {
return ret;
}
// Recolic: compilation issue, temporary disable. TODO
// ret = generic_write_checks(filp, ppos, &len, 0);
// if (ret) {
// return ret;
// }
bh = sb_bread(sb, hellofs_inode->data_block_no);
if (!bh) {
......
#include "khellofs.h"
#include <linux/timekeeping.h>
void hellofs_destroy_inode(struct inode *inode) {
struct hellofs_inode *hellofs_inode = HELLOFS_INODE(inode);
......@@ -17,7 +18,7 @@ void hellofs_fill_inode(struct super_block *sb, struct inode *inode,
// TODO hope we can use hellofs_inode to store timespec
inode->i_atime = inode->i_mtime
= inode->i_ctime
= CURRENT_TIME;
= current_time(inode);
inode->i_private = hellofs_inode;
if (S_ISDIR(hellofs_inode->mode)) {
......@@ -296,4 +297,4 @@ struct dentry *hellofs_lookup(struct inode *dir,
"No inode found for the filename: %s\n",
child_dentry->d_name.name);
return NULL;
}
\ No newline at end of file
}
......@@ -23,7 +23,7 @@ const struct inode_operations hellofs_inode_ops = {
const struct file_operations hellofs_dir_operations = {
.owner = THIS_MODULE,
.readdir = hellofs_readdir,
.iterate = hellofs_iterate,
};
const struct file_operations hellofs_file_operations = {
......
......@@ -41,7 +41,10 @@ struct dentry *hellofs_lookup(struct inode *parent_inode,
int hellofs_mkdir(struct inode *dir, struct dentry *dentry,
umode_t mode);
int hellofs_readdir(struct file *filp, void *dirent, filldir_t filldir);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
#error fs api changed in linux 3.11.0. Please use a better kernel to build my code!
#endif
int hellofs_iterate(struct file *filp, struct dir_context *ctx);
ssize_t hellofs_read(struct file * filp, char __user * buf, size_t len,
loff_t * ppos);
......@@ -107,4 +110,4 @@ int hellofs_alloc_data_block(struct super_block *sb, uint64_t *out_data_block_no
int hellofs_create_inode(struct inode *dir, struct dentry *dentry,
umode_t mode);
#endif /*__KHELLOFS_H__*/
\ No newline at end of file
#endif /*__KHELLOFS_H__*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment