Compare commits

..

No commits in common. "master" and "v1.14" have entirely different histories.

7 changed files with 127 additions and 257 deletions

2
.gitignore vendored
View File

@ -21,5 +21,3 @@ examples/ioctl
examples/logring
examples/pager
examples/uid-filter
examples/mmap-read
examples/mmap-test

View File

@ -1,142 +0,0 @@
language: c
os: linux
dist: trusty
compiler: gcc
env:
global:
- KERNEL_GIT="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
matrix:
include:
# Older version of the kernel
# - name: "Kernel 2.6.13"
# env: KERNEL_BRANCH="v2.6.13" GCC_VER="gcc-4.9"
# addons:
# apt:
# packages:
# - gcc-4.9
# sources:
# - ubuntu-toolchain-r-test
- name: "Kernel 2.6.32"
env: KERNEL_BRANCH="v2.6.32" GCC_VER="gcc-4.9"
addons:
apt:
packages:
- gcc-4.9
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 3.10.0"
env: KERNEL_BRANCH="v3.10" GCC_VER="gcc-4.9"
addons:
apt:
packages:
- gcc-4.9
sources:
- ubuntu-toolchain-r-test
# Here are actively supported kernel
- name: "Kernel 3.16.y LTS"
env: KERNEL_BRANCH="linux-3.16.y" GCC_VER="gcc-5"
addons:
apt:
packages:
- gcc-5
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 4.4.y LTS"
env: KERNEL_BRANCH="linux-4.4.y" GCC_VER="gcc-5"
addons:
apt:
packages:
- gcc-5
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 4.9.y LTS"
env: KERNEL_BRANCH="linux-4.9.y" GCC_VER="gcc-6"
addons:
apt:
packages:
- gcc-6
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 4.14.y LTS"
env: KERNEL_BRANCH="linux-4.14.y" GCC_VER="gcc-7"
addons:
apt:
packages:
- libelf-dev
- gcc-7
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 4.19.y LTS"
env: KERNEL_BRANCH="linux-4.19.y" GCC_VER="gcc-7"
addons:
apt:
packages:
- libelf-dev
- gcc-7
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 5.4.y LTS"
env: KERNEL_BRANCH="linux-5.4.y" GCC_VER="gcc-8"
addons:
apt:
packages:
- libelf-dev
- gcc-8
sources:
- ubuntu-toolchain-r-test
# Stable versions
- name: "Kernel 5.7.y STABLE"
env: KERNEL_BRANCH="linux-5.7.y" GCC_VER="gcc-8"
addons:
apt:
packages:
- libelf-dev
- gcc-8
sources:
- ubuntu-toolchain-r-test
- name: "Kernel 5.8.y STABLE"
env: KERNEL_BRANCH="linux-5.8.y" GCC_VER="gcc-8"
addons:
apt:
packages:
- libelf-dev
- gcc-8
sources:
- ubuntu-toolchain-r-test
allow_failures:
- name: "Kernel 5.8.y STABLE"
# Here checkout kernels
before_script:
- eval "export CC=${GCC_VER}"
- eval "${CC} --version"
- git clone ${KERNEL_GIT} --depth=1 --branch=${KERNEL_BRANCH} ${KERNEL_BRANCH}
- pushd .
- cd $KERNEL_BRANCH
- yes "" | make oldconfig CC=${GCC_VER}
- make prepare CC=${GCC_VER}
- make scripts CC=${GCC_VER}
- popd
# Now build with kernel sources
script:
- make KDIR=${PWD}/${KERNEL_BRANCH} CC=${GCC_VER}
# Not sure if I should cache the kernel source tree...
#cache:
# directories:
# - '$HOME/.sonar/cache'

View File

@ -23,6 +23,8 @@ export
####################################################
SUBDIRS = kfusd libfusd examples
default:
$(MAKE) -C libfusd
$(MAKE) -C kfusd

View File

@ -2,8 +2,6 @@
FUSD: A Linux Framework for User-Space Devices
----------------------------------------------
[![Build Status](https://travis-ci.org/Godzil/fusd.svg?branch=master)](https://travis-ci.org/Godzil/fusd)
**Welcome to FUSD!**
This is FUSD snapshot 20110401, released 18 January 2012. This fork is based

View File

@ -150,6 +150,30 @@ struct fusd_dev_t_s {
/* pointer to allow a dev to be placed on a dev_list */
struct list_head devlist;
};
/**** Function Prototypes ****/
STATIC int maybe_free_fusd_dev(fusd_dev_t *fusd_dev);
STATIC int find_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file);
STATIC int free_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file);
STATIC int fusd_fops_call_send(fusd_file_t *fusd_file_arg,
fusd_msg_t *fusd_msg, struct fusd_transaction** transaction);
STATIC int fusd_fops_call_wait(fusd_file_t *fusd_file_arg,
fusd_msg_t **fusd_msg_reply, struct fusd_transaction* transaction);
STATIC void fusd_fops_call_done(fusd_file_t *fusd_file);
STATIC void fusd_forge_close(fusd_msg_t *msg, fusd_dev_t *fusd_dev);
STATIC int fusd_add_transaction(fusd_file_t *fusd_file, int transid, int subcmd, int size, struct fusd_transaction** out_transaction);
STATIC void fusd_cleanup_transaction(fusd_file_t *fusd_file, struct fusd_transaction* transaction);
STATIC void fusd_remove_transaction(fusd_file_t *fusd_file, struct fusd_transaction* transaction);
STATIC struct fusd_transaction* fusd_find_transaction(fusd_file_t *fusd_file, int transid);
STATIC struct fusd_transaction* fusd_find_transaction_by_pid(fusd_file_t *fusd_file, int pid);
/**** Utility functions & macros ****/

View File

@ -9,7 +9,7 @@ GIT_DESCRIBE = $(shell git describe --dirty --tags)
KERNEL_VER ?= 2.6.32.7
default:
$(MAKE) -C $(KDIR) M=$(PWD) EXTRA_CFLAGS="-I$(PWD)/../include -DGIT_DESCRIBE='\"${GIT_DESCRIBE}\"'" V=1 modules
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS="-I$(PWD)/../include -DGIT_DESCRIBE='\"${GIT_DESCRIBE}\"'" V=1 modules
install:
install -d -m 0755 $(ROOTFS)/lib/modules/$(KERNEL_VER)/kernel/drivers/misc

View File

@ -65,7 +65,6 @@
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/aio.h>
#include <linux/mman.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
@ -76,7 +75,6 @@
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/highmem.h>
#include <linux/sched.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#include <linux/sched/signal.h>
@ -88,6 +86,8 @@
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
#define STATIC
#ifndef GIT_DESCRIBE
#define GIT_DESCRIBE "unknownversion-dirty"
#endif
@ -145,15 +145,10 @@
#define CLASS_DEVICE_DESTROY(a, b) device_destroy(a, b)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
#define GET_USER_PAGES(t,m,s,n,w,f,p,v) get_user_pages_remote(t,m,s,n,(w?FOLL_WRITE:0)|(f?FOLL_FORCE:0),p,v, NULL)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
#define GET_USER_PAGES(t,m,s,n,w,f,p,v) get_user_pages_remote(t,m,s,n,(w?FOLL_WRITE:0)|(f?FOLL_FORCE:0),p,v)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
#define GET_USER_PAGES(t,m,s,n,w,f,p,v) get_user_pages_remote(t,m,s,n,w,f,p,v)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
/* WTH? a small subset of 4.4 have changes that does not exist until 4.9 with a new function name */
#define GET_USER_PAGES(t,m,s,n,w,f,p,v) get_user_pages(t,m,s,n,(w?FOLL_WRITE:0)|(f?FOLL_FORCE:0),p,v)
#else
#define GET_USER_PAGES(t, m, s, n, w, f, p, v) get_user_pages(t,m,s,n,w,f,p,v)
#endif
@ -174,11 +169,11 @@
#error "***FUSD doesn't work before Linux Kernel v2.6.13"
#endif
static struct cdev *fusd_control_cdev;
static struct cdev *fusd_status_cdev;
STATIC struct cdev *fusd_control_cdev;
STATIC struct cdev *fusd_status_cdev;
static dev_t control_id;
static dev_t status_id;
STATIC dev_t control_id;
STATIC dev_t status_id;
static struct CLASS *fusd_class;
@ -191,13 +186,13 @@ static struct device *fusd_status_device;
#endif
/* version number incremented for each registered device */
static int last_version = 1;
STATIC int last_version = 1;
/* version number incremented for each transaction to userspace */
static int last_transid = 1;
STATIC int last_transid = 1;
/* wait queue that is awakened when new devices are registered */
static DECLARE_WAIT_QUEUE_HEAD (new_device_wait);
STATIC DECLARE_WAIT_QUEUE_HEAD (new_device_wait);
/* the list of valid devices, and sem to protect it */
LIST_HEAD (fusd_devlist_head);
@ -215,31 +210,11 @@ MODULE_VERSION(GIT_DESCRIBE);
MODULE_LICENSE ("GPL");
//#endif
/**** Function Prototypes ****/
static int maybe_free_fusd_dev(fusd_dev_t *fusd_dev);
static int find_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file);
static int free_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file);
static int fusd_fops_call_send(fusd_file_t *fusd_file_arg,
fusd_msg_t *fusd_msg, struct fusd_transaction** transaction);
static int fusd_fops_call_wait(fusd_file_t *fusd_file_arg,
fusd_msg_t **fusd_msg_reply, struct fusd_transaction* transaction);
static void fusd_forge_close(fusd_msg_t *msg, fusd_dev_t *fusd_dev);
static int fusd_add_transaction(fusd_file_t *fusd_file, int transid, int subcmd, int size, struct fusd_transaction** out_transaction);
static void fusd_cleanup_transaction(fusd_file_t *fusd_file, struct fusd_transaction* transaction);
static void fusd_remove_transaction(fusd_file_t *fusd_file, struct fusd_transaction* transaction);
static struct fusd_transaction* fusd_find_transaction(fusd_file_t *fusd_file, int transid);
static struct fusd_transaction* fusd_find_transaction_by_pid(fusd_file_t *fusd_file, int pid);
/***************************Debugging Support*****************************/
#ifdef CONFIG_FUSD_DEBUG
static int fusd_debug_level = CONFIG_FUSD_DEBUGLEVEL;
STATIC int fusd_debug_level = CONFIG_FUSD_DEBUGLEVEL;
module_param (fusd_debug_level, int, S_IRUGO);
# define BUFSIZE 1000 /* kernel's kmalloc pool has a 1012-sized bucket */
@ -248,7 +223,7 @@ static int debug_throttle = 0; /* emit a maximum number of debug
out the machine accidentally if a
daemon disappears with open files */
static void rdebug_real(char *fmt, ...)
STATIC void rdebug_real(char *fmt, ...)
{
va_list ap;
int len;
@ -301,7 +276,7 @@ typedef struct
mem_debug_t *mem_debug;
static int fusd_mem_init (void)
STATIC int fusd_mem_init (void)
{
int i;
@ -321,7 +296,7 @@ static int fusd_mem_init (void)
return 0;
}
static void fusd_mem_cleanup (void)
STATIC void fusd_mem_cleanup (void)
{
int i;
int count = 0;
@ -337,7 +312,7 @@ static void fusd_mem_cleanup (void)
kfree(mem_debug);
}
static void fusd_mem_add (void *ptr, int line, int size)
STATIC void fusd_mem_add (void *ptr, int line, int size)
{
int i;
@ -357,7 +332,7 @@ static void fusd_mem_add (void *ptr, int line, int size)
RDEBUG(1, "WARNING - memdebug out of space!!!!");
}
static void fusd_mem_del (void *ptr)
STATIC void fusd_mem_del (void *ptr)
{
int i;
for ( i = 0; i < MAX_MEM_DEBUG; i++ )
@ -371,7 +346,7 @@ static void fusd_mem_del (void *ptr)
RDEBUG(2, "WARNING - memdebug is confused!!!!");
}
static void *fusd_kmalloc (size_t size, int type, int line)
STATIC void *fusd_kmalloc (size_t size, int type, int line)
{
void *ptr = kmalloc(size, type);
down(&fusd_memdebug_sem);
@ -380,7 +355,7 @@ static void *fusd_kmalloc (size_t size, int type, int line)
return ptr;
}
static void fusd_kfree (void *ptr)
STATIC void fusd_kfree (void *ptr)
{
down(&fusd_memdebug_sem);
fusd_mem_del(ptr);
@ -388,7 +363,7 @@ static void fusd_kfree (void *ptr)
up(&fusd_memdebug_sem);
}
static void *fusd_vmalloc (size_t size, int line)
STATIC void *fusd_vmalloc (size_t size, int line)
{
void *ptr = vmalloc(size);
down(&fusd_memdebug_sem);
@ -397,7 +372,7 @@ static void *fusd_vmalloc (size_t size, int line)
return ptr;
}
static void fusd_vfree (void *ptr)
STATIC void fusd_vfree (void *ptr)
{
down(&fusd_memdebug_sem);
fusd_mem_del(ptr);
@ -416,7 +391,7 @@ static void fusd_vfree (void *ptr)
/************** STATE MANAGEMENT AND BOOKKEEPING UTILITIES ***************/
/*************************************************************************/
static inline void init_fusd_msg(fusd_msg_t *fusd_msg)
STATIC inline void init_fusd_msg(fusd_msg_t *fusd_msg)
{
if (fusd_msg == NULL)
return;
@ -429,7 +404,7 @@ static inline void init_fusd_msg(fusd_msg_t *fusd_msg)
/*
* free a fusd_msg, and NULL out the pointer that points to that fusd_msg.
*/
static inline void free_fusd_msg(fusd_msg_t **fusd_msg)
STATIC inline void free_fusd_msg(fusd_msg_t **fusd_msg)
{
if (fusd_msg == NULL || *fusd_msg == NULL)
return;
@ -450,7 +425,7 @@ static inline void free_fusd_msg(fusd_msg_t **fusd_msg)
* num_files<array_size/4, the size is halved. Array is kept as is if
* the malloc fails. Returns a pointer to the new file struct or NULL
* if there isn't one. */
static fusd_file_t **fusd_dev_adjsize(fusd_dev_t *fusd_dev)
STATIC fusd_file_t **fusd_dev_adjsize(fusd_dev_t *fusd_dev)
{
fusd_file_t **old_array;
int old_size;
@ -514,7 +489,7 @@ static fusd_file_t **fusd_dev_adjsize(fusd_dev_t *fusd_dev)
*
* Returns: 1 if the device was freed
* 0 if the device still exists (and can be unlocked) */
static int maybe_free_fusd_dev(fusd_dev_t *fusd_dev)
STATIC int maybe_free_fusd_dev(fusd_dev_t *fusd_dev)
{
fusd_msgC_t *ptr, *next;
@ -588,7 +563,7 @@ static int maybe_free_fusd_dev(fusd_dev_t *fusd_dev)
* device state itself is freed.
*
*/
static void zombify_dev(fusd_dev_t *fusd_dev)
STATIC void zombify_dev(fusd_dev_t *fusd_dev)
{
int i;
@ -613,7 +588,7 @@ static void zombify_dev(fusd_dev_t *fusd_dev)
* returns index if found, -1 if not found. ASSUMES WE HAVE A VALID
* fusd_dev. fusd_file may be NULL if we are searching for an empty
* slot. */
static int find_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file)
STATIC int find_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file)
{
int i, num_files = fusd_dev->num_files;
fusd_file_t **files = fusd_dev->files;
@ -632,7 +607,7 @@ static int find_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file)
* freed. If the device is freed, then do not try to unlock it!
* (Callers: Check the return value before unlocking!)
*/
static int free_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file)
STATIC int free_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file)
{
int i;
struct list_head *tmp, *it;
@ -698,7 +673,7 @@ static int free_fusd_file(fusd_dev_t *fusd_dev, fusd_file_t *fusd_file)
* call on that file descriptor -- well, we lose. Clear state of that
* old syscall out and continue as usual.
*/
static struct fusd_transaction *fusd_find_incomplete_transaction(fusd_file_t *fusd_file, int subcmd)
STATIC struct fusd_transaction *fusd_find_incomplete_transaction(fusd_file_t *fusd_file, int subcmd)
{
struct fusd_transaction *transaction = fusd_find_transaction_by_pid(fusd_file, current->pid);
if (transaction == NULL)
@ -717,7 +692,7 @@ static struct fusd_transaction *fusd_find_incomplete_transaction(fusd_file_t *fu
return transaction;
}
static int send_to_dev(fusd_dev_t *fusd_dev, fusd_msg_t *fusd_msg, int locked)
STATIC int send_to_dev(fusd_dev_t *fusd_dev, fusd_msg_t *fusd_msg, int locked)
{
fusd_msgC_t *fusd_msgC;
@ -760,7 +735,7 @@ zombie_dev:
* free_fusd_file, when we throw away a reply that had been
* pending for a restart.
*/
static void fusd_forge_close(fusd_msg_t *msg, fusd_dev_t *fusd_dev)
STATIC void fusd_forge_close(fusd_msg_t *msg, fusd_dev_t *fusd_dev)
{
RDEBUG(2, "/dev/%s tried to complete an open for transid %ld, "
"forging a close", NAME(fusd_dev), msg->parm.fops_msg.transid);
@ -776,7 +751,7 @@ static void fusd_forge_close(fusd_msg_t *msg, fusd_dev_t *fusd_dev)
* NOTE - we are already holding the lock on fusd_file_arg when this
* function is called, but NOT the lock on the fusd_dev
*/
static int fusd_fops_call_send(fusd_file_t *fusd_file_arg,
STATIC int fusd_fops_call_send(fusd_file_t *fusd_file_arg,
fusd_msg_t *fusd_msg, struct fusd_transaction **transaction)
{
fusd_dev_t *fusd_dev;
@ -850,7 +825,7 @@ invalid_file:
* NOTE - we are already holding the lock on fusd_file_arg when this
* function is called, but NOT the lock on the fusd_dev
*/
static int fusd_fops_call_wait(fusd_file_t *fusd_file_arg,
STATIC int fusd_fops_call_wait(fusd_file_t *fusd_file_arg,
fusd_msg_t **fusd_msg_reply, struct fusd_transaction *transaction)
{
fusd_dev_t *fusd_dev;
@ -956,6 +931,16 @@ zombie_dev:
return -EPIPE;
}
/* fusd client system call handlers should call this after they call
* fops_call, to destroy the message that was returned to them. */
STATIC void fusd_transaction_done(struct fusd_transaction *transaction)
{
transaction->transid = -1;
transaction->pid = 0;
}
/********* Functions for opening a FUSD device *******************/
@ -1097,7 +1082,7 @@ int fusd_dev_add_file(struct file *file, fusd_dev_t *fusd_dev, fusd_file_t **fus
return 0;
}
static struct fusd_dev_t_s *find_user_device(int dev_id)
STATIC struct fusd_dev_t_s *find_user_device(int dev_id)
{
struct list_head *entry;
down(&fusd_devlist_sem);
@ -1118,7 +1103,7 @@ static struct fusd_dev_t_s *find_user_device(int dev_id)
* A client has called open() has been called on a registered device.
* See comment higher up for detailed notes on this function.
*/
static int fusd_client_open(struct inode *inode, struct file *file)
STATIC int fusd_client_open(struct inode *inode, struct file *file)
{
int retval;
int device_freed = 0;
@ -1203,7 +1188,7 @@ static int fusd_client_open(struct inode *inode, struct file *file)
/* close() has been called on a registered device. like
* fusd_client_open, we must lock the entire device. */
static int fusd_client_release(struct inode *inode, struct file *file)
STATIC int fusd_client_release(struct inode *inode, struct file *file)
{
int retval;
fusd_file_t *fusd_file;
@ -1244,7 +1229,7 @@ invalid_file:
return -EPIPE;
}
static ssize_t fusd_client_read(struct file *file, char *buf,
STATIC ssize_t fusd_client_read(struct file *file, char *buf,
size_t count, loff_t *offset)
{
fusd_dev_t *fusd_dev;
@ -1341,7 +1326,7 @@ zombie_dev:
return -EPIPE;
}
static int fusd_add_transaction(fusd_file_t *fusd_file, int transid, int subcmd, int size,
STATIC int fusd_add_transaction(fusd_file_t *fusd_file, int transid, int subcmd, int size,
struct fusd_transaction **out_transaction)
{
struct fusd_transaction *transaction = (struct fusd_transaction *) KMALLOC(sizeof(struct fusd_transaction),
@ -1365,13 +1350,13 @@ static int fusd_add_transaction(fusd_file_t *fusd_file, int transid, int subcmd,
return 0;
}
static void fusd_cleanup_transaction(fusd_file_t *fusd_file, struct fusd_transaction *transaction)
STATIC void fusd_cleanup_transaction(fusd_file_t *fusd_file, struct fusd_transaction *transaction)
{
free_fusd_msg(&transaction->msg_in);
fusd_remove_transaction(fusd_file, transaction);
}
static void fusd_remove_transaction(fusd_file_t *fusd_file, struct fusd_transaction *transaction)
STATIC void fusd_remove_transaction(fusd_file_t *fusd_file, struct fusd_transaction *transaction)
{
down(&fusd_file->transactions_sem);
list_del(&transaction->list);
@ -1380,7 +1365,7 @@ static void fusd_remove_transaction(fusd_file_t *fusd_file, struct fusd_transact
KFREE(transaction);
}
static struct fusd_transaction *fusd_find_transaction(fusd_file_t *fusd_file, int transid)
STATIC struct fusd_transaction *fusd_find_transaction(fusd_file_t *fusd_file, int transid)
{
struct list_head *i;
down(&fusd_file->transactions_sem);
@ -1398,7 +1383,7 @@ static struct fusd_transaction *fusd_find_transaction(fusd_file_t *fusd_file, in
return NULL;
}
static struct fusd_transaction *fusd_find_transaction_by_pid(fusd_file_t *fusd_file, int pid)
STATIC struct fusd_transaction *fusd_find_transaction_by_pid(fusd_file_t *fusd_file, int pid)
{
struct list_head *i;
down(&fusd_file->transactions_sem);
@ -1416,7 +1401,7 @@ static struct fusd_transaction *fusd_find_transaction_by_pid(fusd_file_t *fusd_f
return NULL;
}
static ssize_t fusd_client_write(struct file *file,
STATIC ssize_t fusd_client_write(struct file *file,
const char *buffer,
size_t length,
loff_t *offset)
@ -1514,10 +1499,10 @@ zombie_dev:
}
#ifndef HAVE_UNLOCKED_IOCTL
static int fusd_client_ioctl(struct inode *inode, struct file *file,
STATIC int fusd_client_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
#else
static long fusd_client_unlocked_ioctl (struct file *file,
STATIC long fusd_client_unlocked_ioctl (struct file *file,
unsigned int cmd, unsigned long arg)
#endif
{
@ -1614,14 +1599,15 @@ static void fusd_client_mm_open(struct vm_area_struct *vma);
static void fusd_client_mm_close(struct vm_area_struct *vma);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
static vm_fault_t fusd_client_fault (struct vm_fault *vmf);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
/* int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf); */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
static int fusd_client_fault (struct vm_fault *vmf);
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30)
static int fusd_client_fault (struct vm_area_struct *vma, struct vm_fault *vmf);
#else
static int fusd_client_fault(struct vm_area_struct *vma, struct vm_fault *vmf, int *type);
#endif
static struct vm_operations_struct fusd_remap_vm_ops = {
@ -1735,9 +1721,7 @@ zombie_dev:
return -EPIPE;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
static vm_fault_t fusd_client_fault (struct vm_fault *vmf)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
static int fusd_client_fault (struct vm_fault *vmf)
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30)
static int fusd_client_fault (struct vm_area_struct *vma, struct vm_fault *vmf)
@ -1811,7 +1795,7 @@ out:
* cached from the driver.
*
*/
static unsigned int fusd_client_poll(struct file *file, poll_table *wait)
STATIC unsigned int fusd_client_poll(struct file *file, poll_table *wait)
{
fusd_dev_t *fusd_dev;
fusd_file_t *fusd_file;
@ -1888,7 +1872,7 @@ invalid_file:
}
#ifndef HAVE_UNLOCKED_IOCTL
static struct file_operations fusd_client_fops = {
STATIC struct file_operations fusd_client_fops = {
.owner = THIS_MODULE,
.open = fusd_client_open,
.release = fusd_client_release,
@ -1899,7 +1883,7 @@ static struct file_operations fusd_client_fops = {
.mmap = fusd_client_mmap
};
#else
static struct file_operations fusd_client_fops = {
STATIC struct file_operations fusd_client_fops = {
.owner = THIS_MODULE,
.open = fusd_client_open,
.release = fusd_client_release,
@ -1916,7 +1900,7 @@ static struct file_operations fusd_client_fops = {
/*************************************************************************/
static fusd_file_t *find_fusd_reply_file(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
STATIC fusd_file_t *find_fusd_reply_file(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
{
/* first, try the hint */
int i = msg->parm.fops_msg.hint;
@ -1941,7 +1925,7 @@ static fusd_file_t *find_fusd_reply_file(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
/* Process an incoming reply to a message dispatched by
* fusd_fops_call. Called by fusd_write when a driver writes to
* /dev/fusd. */
static int fusd_fops_reply(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
STATIC int fusd_fops_reply(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
{
fusd_file_t *fusd_file;
struct fusd_transaction *transaction;
@ -1990,7 +1974,7 @@ discard:
}
/* special function to process responses to POLL_DIFF */
static int fusd_polldiff_reply(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
STATIC int fusd_polldiff_reply(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
{
fusd_file_t *fusd_file;
@ -2017,7 +2001,13 @@ static int fusd_polldiff_reply(fusd_dev_t *fusd_dev, fusd_msg_t *msg)
return 0;
}
static int fusd_register_device(fusd_dev_t *fusd_dev,
STATIC int systest(struct super_block *sb, void *data)
{
return 1;
}
STATIC int fusd_register_device(fusd_dev_t *fusd_dev,
register_msg_t register_msg)
{
int error = 0;
@ -2144,7 +2134,7 @@ register_failed:
/****************************************************************************/
/* open() called on /dev/fusd itself */
static int fusd_open(struct inode *inode, struct file *file)
STATIC int fusd_open(struct inode *inode, struct file *file)
{
fusd_dev_t *fusd_dev = NULL;
fusd_file_t **file_array = NULL;
@ -2189,7 +2179,7 @@ dev_malloc_failed:
/* close() called on /dev/fusd itself. destroy the device that
* was registered by it, if any. */
static int fusd_release(struct inode *inode, struct file *file)
STATIC int fusd_release(struct inode *inode, struct file *file)
{
fusd_dev_t *fusd_dev;
@ -2248,7 +2238,7 @@ invalid_dev:
* This function processes messages coming from userspace device drivers
* (i.e., writes to the /dev/fusd control channel.)
*/
static ssize_t fusd_process_write(struct file *file,
STATIC ssize_t fusd_process_write(struct file *file,
const char *user_msg_buffer, size_t user_msg_len,
const char *user_data_buffer, size_t user_data_len)
{
@ -2396,7 +2386,7 @@ invalid_dev:
return -EPIPE;
}
static ssize_t fusd_write(struct file *file,
STATIC ssize_t fusd_write(struct file *file,
const char *buffer,
size_t length,
loff_t *offset)
@ -2406,7 +2396,7 @@ static ssize_t fusd_write(struct file *file,
}
#ifndef HAVE_UNLOCKED_IOCTL
static ssize_t fusd_writev(struct file *file,
STATIC ssize_t fusd_writev(struct file *file,
const struct iovec *iov,
unsigned long count,
loff_t *offset)
@ -2424,7 +2414,7 @@ static ssize_t fusd_writev(struct file *file,
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
ssize_t fusd_write_iter (struct kiocb *iocb, struct iov_iter *iov)
{
// unsigned long count = iov_iter_count(iov);
unsigned long count = iov_iter_count(iov);
char *msg, *data;
size_t msg_len, data_len;
@ -2447,7 +2437,7 @@ ssize_t fusd_write_iter (struct kiocb *iocb, struct iov_iter *iov)
data, data_len);
}
#else
static ssize_t fusd_aio_write (struct kiocb *iocb,
STATIC ssize_t fusd_aio_write (struct kiocb *iocb,
const struct iovec *iov,
unsigned long count,
loff_t offset)
@ -2465,10 +2455,10 @@ static ssize_t fusd_aio_write (struct kiocb *iocb,
#endif
#ifndef HAVE_UNLOCKED_IOCTL
static int fusd_ioctl(struct inode *inode, struct file *file,
STATIC int fusd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
#else
static long fusd_unlocked_ioctl (struct file *file,
STATIC long fusd_unlocked_ioctl (struct file *file,
unsigned int cmd, unsigned long arg)
#endif
{
@ -2538,7 +2528,7 @@ static long fusd_unlocked_ioctl (struct file *file,
* message queue.) */
/* do a "header" read: used by fusd_read */
static int fusd_read_header(char *user_buffer, size_t user_length, fusd_msg_t *msg)
STATIC int fusd_read_header(char *user_buffer, size_t user_length, fusd_msg_t *msg)
{
int len = sizeof(fusd_msg_t);
@ -2554,7 +2544,7 @@ static int fusd_read_header(char *user_buffer, size_t user_length, fusd_msg_t *m
}
/* do a "data" read: used by fusd_read */
static int fusd_read_data(char *user_buffer, size_t user_length, fusd_msg_t *msg)
STATIC int fusd_read_data(char *user_buffer, size_t user_length, fusd_msg_t *msg)
{
int len = msg->datalen;
@ -2578,7 +2568,7 @@ static int fusd_read_data(char *user_buffer, size_t user_length, fusd_msg_t *msg
return len;
}
static ssize_t fusd_read(struct file *file,
STATIC ssize_t fusd_read(struct file *file,
char *user_buffer, /* The buffer to fill with data */
size_t user_length, /* The length of the buffer */
loff_t *offset) /* Our offset in the file */
@ -2661,7 +2651,7 @@ invalid_dev:
}
/* a poll on /dev/fusd itself (the control channel) */
static unsigned int fusd_poll(struct file *file, poll_table *wait)
STATIC unsigned int fusd_poll(struct file *file, poll_table *wait)
{
fusd_dev_t *fusd_dev;
GET_FUSD_DEV(file->private_data, fusd_dev);
@ -2677,7 +2667,7 @@ invalid_dev:
}
#ifndef HAVE_UNLOCKED_IOCTL
static struct file_operations fusd_fops = {
STATIC struct file_operations fusd_fops = {
.owner = THIS_MODULE,
.open = fusd_open,
.read = fusd_read,
@ -2688,7 +2678,7 @@ static struct file_operations fusd_fops = {
.poll = fusd_poll,
};
#else
static struct file_operations fusd_fops = {
STATIC struct file_operations fusd_fops = {
.owner = THIS_MODULE,
.open = fusd_open,
.read = fusd_read,
@ -2716,7 +2706,7 @@ typedef struct fusd_status_state {
} fusd_statcontext_t;
/* open() called on /dev/fusd/status */
static int fusd_status_open(struct inode *inode, struct file *file)
STATIC int fusd_status_open(struct inode *inode, struct file *file)
{
int error = 0;
fusd_statcontext_t *fs;
@ -2740,7 +2730,7 @@ out:
}
/* close on /dev/fusd_status */
static int fusd_status_release(struct inode *inode, struct file *file)
STATIC int fusd_status_release(struct inode *inode, struct file *file)
{
fusd_statcontext_t *fs = (fusd_statcontext_t *) file->private_data;
@ -2756,10 +2746,10 @@ static int fusd_status_release(struct inode *inode, struct file *file)
/* ioctl() on /dev/fusd/status */
#ifndef HAVE_UNLOCKED_IOCTL
static int fusd_status_ioctl(struct inode *inode, struct file *file,
STATIC int fusd_status_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
#else
static long fusd_status_unlocked_ioctl (struct file *file,
STATIC long fusd_status_unlocked_ioctl (struct file *file,
unsigned int cmd, unsigned long arg)
#endif
{
@ -2790,7 +2780,7 @@ static long fusd_status_unlocked_ioctl (struct file *file,
* If there isn't at least space_needed difference between buf_size
* and len, the existing contents are moved into a larger buffer.
*/
static int maybe_expand_buffer(char **buf, int *buf_size, int len,
STATIC int maybe_expand_buffer(char **buf, int *buf_size, int len,
int space_needed)
{
if (*buf_size - len < space_needed) {
@ -2811,7 +2801,7 @@ static int maybe_expand_buffer(char **buf, int *buf_size, int len,
}
/* Build a text buffer containing current fusd status. */
static void fusd_status_build_text(fusd_statcontext_t *fs)
STATIC void fusd_status_build_text(fusd_statcontext_t *fs)
{
int buf_size = 512;
char *buf = KMALLOC(buf_size, GFP_KERNEL);
@ -2866,7 +2856,7 @@ out:
}
/* Build the binary version of status */
static void fusd_status_build_binary(fusd_statcontext_t *fs)
STATIC void fusd_status_build_binary(fusd_statcontext_t *fs)
{
int buf_size = 512;
char *buf = KMALLOC(buf_size, GFP_KERNEL);
@ -2917,7 +2907,7 @@ out:
fs->need_new_status = 0;
}
static ssize_t fusd_status_read(struct file *file,
STATIC ssize_t fusd_status_read(struct file *file,
char *user_buffer, /* The buffer to fill with data */
size_t user_length, /* The length of the buffer */
loff_t *offset) /* Our offset in the file */
@ -2960,7 +2950,7 @@ static ssize_t fusd_status_read(struct file *file,
}
/* a poll on /dev/fusd itself (the control channel) */
static unsigned int fusd_status_poll(struct file *file, poll_table *wait)
STATIC unsigned int fusd_status_poll(struct file *file, poll_table *wait)
{
fusd_statcontext_t *fs = (fusd_statcontext_t *) file->private_data;
@ -2973,7 +2963,7 @@ static unsigned int fusd_status_poll(struct file *file, poll_table *wait)
}
#ifndef HAVE_UNLOCKED_IOCTL
static struct file_operations fusd_status_fops = {
STATIC struct file_operations fusd_status_fops = {
.owner = THIS_MODULE,
.open = fusd_status_open,
.ioctl = fusd_status_ioctl,
@ -2982,7 +2972,7 @@ static struct file_operations fusd_status_fops = {
.poll = fusd_status_poll,
};
#else
static struct file_operations fusd_status_fops = {
STATIC struct file_operations fusd_status_fops = {
.owner = THIS_MODULE,
.open = fusd_status_open,
.unlocked_ioctl = fusd_status_unlocked_ioctl,
@ -2995,7 +2985,7 @@ static struct file_operations fusd_status_fops = {
/*************************************************************************/
static int init_fusd(void)
STATIC int init_fusd(void)
{
int retval;
@ -3106,7 +3096,7 @@ fail0:
return retval;
}
static void cleanup_fusd(void)
STATIC void cleanup_fusd(void)
{
RDEBUG(1, "cleaning up");