Skip to content

Commit

Permalink
[argo-module] Add 4.19 kernel support
Browse files Browse the repository at this point in the history
OXT-1616

Signed-off-by: Nicholas Tsirakis <[email protected]>
  • Loading branch information
Nicholas Tsirakis committed Jun 13, 2019
1 parent 44a7f21 commit d4a0ec9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions argo-linux/argo-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -3078,8 +3078,8 @@ static int
allocate_fd_with_private (void *private)
{
int fd;
const char * name = "";
struct file *f;
struct qstr name = { .name = "" };
struct path path;
struct inode *ind;

Expand All @@ -3091,34 +3091,42 @@ allocate_fd_with_private (void *private)
if ( fd < 0 )
return fd;

#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) )
path.dentry = d_alloc_pseudo(argo_mnt->mnt_sb, &name);
if ( unlikely(!path.dentry) )
{
if (unlikely(!path.dentry)) {
put_unused_fd(fd);
return -ENOMEM;
return -ENOMEM;
}
#endif

ind = new_inode(argo_mnt->mnt_sb);
ind->i_ino = get_next_ino();
ind->i_fop = argo_mnt->mnt_root->d_inode->i_fop;
ind->i_state = argo_mnt->mnt_root->d_inode->i_state;
ind->i_mode = argo_mnt->mnt_root->d_inode->i_mode;
ind->i_uid = current_fsuid();
ind->i_gid = current_fsgid();
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) )
d_instantiate(path.dentry, ind);

path.mnt = mntget(argo_mnt);
#endif

DEBUG_APPLE;
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) )
f = alloc_file(&path, FMODE_READ | FMODE_WRITE, &argo_fops_stream);
#else
f = alloc_file_pseudo(ind, argo_mnt, name, O_RDWR, &argo_fops_stream);
#endif
if ( !f )
{
//FIXME putback fd?
return -ENFILE;
}

f->private_data = private;
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) )
f->f_flags = O_RDWR;
#endif
fd_install (fd, f);

return fd;
Expand Down

0 comments on commit d4a0ec9

Please sign in to comment.