Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56bf9b87fe | ||
|
|
081f817cac | ||
|
|
483be78d0d | ||
|
|
61f72c675d | ||
|
|
30f606be39 | ||
|
|
41e61a81f8 | ||
|
|
ac6def392c | ||
|
|
3e71c6e74f | ||
|
|
9116a9917b | ||
|
|
f184634d5f | ||
|
|
a765b0745d | ||
|
|
0132d11b4b | ||
|
|
f404dd7061 | ||
|
|
d8fea5550c | ||
|
|
101f3687ff | ||
|
|
68b4fd7b40 | ||
|
|
eb9511d9b3 | ||
|
|
43b1069b54 | ||
|
|
d27a3f2ee1 | ||
|
|
2ce7c94d11 | ||
|
|
36fd2b86c5 | ||
|
|
c37e562e5f | ||
|
|
57ae74c803 | ||
|
|
a54adc616d | ||
|
|
095ac4569a | ||
|
|
70f58ed6dc | ||
|
|
596df479c2 | ||
|
|
1cf7fd077c | ||
|
|
75a05048a4 | ||
|
|
0ce298ca33 | ||
|
|
fa61f857a7 | ||
|
|
684a150a21 | ||
|
|
4db826209e | ||
|
|
1b50ad2d74 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -21,3 +21,5 @@ examples/ioctl
|
||||
examples/logring
|
||||
examples/pager
|
||||
examples/uid-filter
|
||||
examples/mmap-read
|
||||
examples/mmap-test
|
||||
|
||||
142
.travis.yml
Normal file
142
.travis.yml
Normal file
@ -0,0 +1,142 @@
|
||||
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'
|
||||
|
||||
2
Makefile
2
Makefile
@ -23,8 +23,6 @@ export
|
||||
|
||||
####################################################
|
||||
|
||||
SUBDIRS = kfusd libfusd examples
|
||||
|
||||
default:
|
||||
$(MAKE) -C libfusd
|
||||
$(MAKE) -C kfusd
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
FUSD: A Linux Framework for User-Space Devices
|
||||
----------------------------------------------
|
||||
|
||||
[](https://travis-ci.org/Godzil/fusd)
|
||||
|
||||
**Welcome to FUSD!**
|
||||
|
||||
This is FUSD snapshot 20110401, released 18 January 2012. This fork is based
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
% Released under open-source, BSD license
|
||||
% See LICENSE file for full license
|
||||
%
|
||||
% $Id: fusd.tex,v 1.63 2003/08/20 22:00:55 jelson Exp $
|
||||
|
||||
\documentclass{article}
|
||||
\addtolength{\topmargin}{-.5in} % repairing LaTeX's huge margins...
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
%
|
||||
% $Id: html.sty,v 1.1 2001/05/12 00:38:48 cvs Exp $
|
||||
% LaTeX2HTML Version 99.2 : html.sty
|
||||
%
|
||||
% This file contains definitions of LaTeX commands which are
|
||||
|
||||
@ -1,23 +1,27 @@
|
||||
SRC = console-read.c drums3.c echo.c helloworld.c logring.c pager.c\
|
||||
drums2.c drums.c ioctl.c uid-filter.c
|
||||
OBJ = console-read.o drums3.o echo.o helloworld.o logring.o pager.o\
|
||||
drums2.o drums.o ioctl.o uid-filter.o
|
||||
drums2.o drums.o ioctl.o uid-filter.o mmap-test.o
|
||||
TARGETS = console-read drums3 echo helloworld logring pager\
|
||||
drums2 drums ioctl uid-filter
|
||||
drums2 drums ioctl uid-filter mmap-test
|
||||
|
||||
default: $(TARGETS)
|
||||
default: $(TARGETS) mmap-read
|
||||
|
||||
install: $(TARGETS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d $(TARGETS) gmon.out *~
|
||||
|
||||
$(TARGETS): %: %.c
|
||||
mmap-read: mmap-read.c
|
||||
$(CC) $< -o $@
|
||||
|
||||
$(TARGETS): %: %.c ../libfusd/libfusd.a
|
||||
$(CC) $(GCF) $< -o $@ ../libfusd/libfusd.a
|
||||
|
||||
%.d: %.c
|
||||
$(CC) -M $(CFLAGS) $< > $@.$$$$; sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$
|
||||
|
||||
|
||||
ifeq ($(MAKECMDGOALS),target)
|
||||
include $(SRC:.c=.d)
|
||||
endif
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
* need a template from which to start on a real driver, use pager.c
|
||||
* instead.
|
||||
*
|
||||
* $Id: console-read.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
* directory: /dev/drums/bam, /dev/drums/bum, etc. If you cat one of
|
||||
* these devices, it returns a string that's the same as its name.
|
||||
*
|
||||
* $Id: drums.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -47,10 +47,10 @@
|
||||
* to remember if this user has read before; cat /dev/drums/X will
|
||||
* read infinitely
|
||||
*
|
||||
* $Id: drums2.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -43,7 +43,6 @@
|
||||
* However, it also prints a prompt to the console, asking the user if
|
||||
* how loud the drums should be.
|
||||
*
|
||||
* $Id: drums3.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
* stored. Then, when you read (e.g. "cat /dev/echo"), you get back
|
||||
* whatever you wrote most recently.
|
||||
*
|
||||
* $Id: echo.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
2
examples/fusd.rules
Normal file
2
examples/fusd.rules
Normal file
@ -0,0 +1,2 @@
|
||||
SUBSYSTEM=="fusd", NAME="fusd/%k"
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
* hello-world: Simply creates a device called /dev/hello-world, which
|
||||
* greets you when you try to get it.
|
||||
*
|
||||
* $Id: helloworld.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
/* EXAMPLE START helloworld.c */
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
* the other examples, anyway), because this program is both an
|
||||
* example and part of the regression test suite.
|
||||
*
|
||||
* $Id: ioctl.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -71,7 +71,6 @@
|
||||
* but want to use it on a system that does not have FUSD, check out
|
||||
* emlog at http://www.circlemud.org/~jelson/software/emlog.
|
||||
*
|
||||
* $Id: logring.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
110
examples/mmap-read.c
Normal file
110
examples/mmap-read.c
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2003 The Regents of the University of California. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* FUSD - The Framework for UserSpace Devices - Example program
|
||||
*
|
||||
* This mmap a file/device and change it a bit.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static void hexdump(void *ptr_r, int size)
|
||||
{
|
||||
int J, I;
|
||||
unsigned char *ptr = ptr_r;
|
||||
unsigned long Addr = 0;
|
||||
if (ptr == NULL) {
|
||||
puts("NULL POINTER");
|
||||
puts("-------------------------------------------------------------------------------------");
|
||||
return;
|
||||
}
|
||||
while (Addr <= size) {
|
||||
for (J = 0; J < 2; J++) {
|
||||
printf("%08p: ", Addr + ptr);
|
||||
for (I = 0; I < 16; I++, Addr++) { if (Addr <= size) { printf("%02lX ", (unsigned char) ptr[Addr]); } else { printf(" "); } }
|
||||
printf(" | "); Addr -= 16;
|
||||
for (I = 0; I < 16; I++, Addr++) { if (Addr <= size) { putchar(isprint(ptr[Addr]) ? ptr[Addr] : '.'); } else { putchar(' '); } }
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
puts("-------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd, i;
|
||||
char *ptr;
|
||||
int size = 0;
|
||||
struct stat FileStat;
|
||||
|
||||
srand((unsigned int) time(NULL));
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s file size");
|
||||
}
|
||||
|
||||
fd = open(argv[1], O_RDWR);
|
||||
size = atoi(argv[2]);
|
||||
|
||||
ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
|
||||
printf("ptr = %p\n", ptr);
|
||||
|
||||
if ((ptr != NULL) && (ptr != MAP_FAILED)) {
|
||||
|
||||
hexdump(ptr, size);
|
||||
|
||||
/* Let's do some changes */
|
||||
for (i = 0; i < 128; i++) {
|
||||
ptr[i] ^= rand() % 0x100;
|
||||
}
|
||||
|
||||
msync(ptr, size, MS_SYNC|MS_INVALIDATE);
|
||||
|
||||
hexdump(ptr, size);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
146
examples/mmap-test.c
Normal file
146
examples/mmap-test.c
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2003 The Regents of the University of California. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* FUSD - The Framework for UserSpace Devices - Example program
|
||||
*
|
||||
* This example creates a a mmap-able buffer.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "fusd.h"
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
|
||||
static char *mmap_buffer;
|
||||
|
||||
static void hexdump(void *ptr_r, int size)
|
||||
{
|
||||
int J, I;
|
||||
unsigned char *ptr = ptr_r;
|
||||
unsigned long Addr = 0;
|
||||
if (ptr == NULL) {
|
||||
puts("NULL POINTER");
|
||||
puts("-------------------------------------------------------------------------------------");
|
||||
return;
|
||||
}
|
||||
while (Addr <= size) {
|
||||
for (J = 0; J < 2; J++) {
|
||||
printf("%08p: ", Addr + ptr);
|
||||
for (I = 0; I < 16; I++, Addr++) { if (Addr <= size) { printf("%02lX ", (unsigned char) ptr[Addr]); } else { printf(" "); } }
|
||||
printf(" | "); Addr -= 16;
|
||||
for (I = 0; I < 16; I++, Addr++) { if (Addr <= size) { putchar(isprint(ptr[Addr]) ? ptr[Addr] : '.'); } else { putchar(' '); } }
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
puts("-------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
ssize_t mmaptest_read(struct fusd_file_info *file, char *user_buffer,
|
||||
size_t user_length, loff_t *offset)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (*offset > BUFFER_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = MIN(user_length + (*offset), BUFFER_SIZE);
|
||||
memcpy(user_buffer, mmap_buffer + (*offset), len);
|
||||
*offset += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
int tester_mmap(struct fusd_file_info *file, int offset, size_t length, int prot, int flags,
|
||||
void **addr, size_t *out_length)
|
||||
{
|
||||
|
||||
printf("Got a mmap request from PID:%d [offset=%d, size=%d, prot=%X, flags=%X, addr=%p]\n",
|
||||
file->pid, offset, length, prot, flags, *addr);
|
||||
|
||||
if (length <= BUFFER_SIZE) {
|
||||
|
||||
*addr = mmap_buffer;
|
||||
*out_length = BUFFER_SIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int do_open(struct fusd_file_info *file)
|
||||
{
|
||||
/* opens and closes always succeed */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_close(struct fusd_file_info *file)
|
||||
{
|
||||
/* Show content of the buffer */
|
||||
hexdump(mmap_buffer, 512);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct fusd_file_operations drums_fops = {
|
||||
open: do_open,
|
||||
read: mmaptest_read,
|
||||
mmap: tester_mmap,
|
||||
close: do_close
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
mmap_buffer = (char *)mmap(NULL, BUFFER_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
|
||||
|
||||
if (fusd_register("mmap-tester", "mmaptest", "mmap-tester", 0666, NULL, &drums_fops) < 0) {
|
||||
fprintf(stderr, "mmap-tester register failed: %m\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(mmap_buffer, 0xAA, BUFFER_SIZE);
|
||||
|
||||
fprintf(stderr, "calling fusd_run...\n");
|
||||
fusd_run();
|
||||
return 0;
|
||||
}
|
||||
@ -60,7 +60,6 @@
|
||||
* If you close the FD and then reopen it, there will be a race (pages
|
||||
* that arrive between the close and open will not be delivered).
|
||||
*
|
||||
* $Id: pager.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -366,12 +365,12 @@ static int fusd_success(struct fusd_file_info *file)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* register the input device */
|
||||
fusd_simple_register("/dev/pager/input", "pager", "input", 0666, NULL,
|
||||
fusd_simple_register("/dev/pager/input", "pager", "pager!input", 0666, NULL,
|
||||
open: fusd_success, close: fusd_success,
|
||||
write: pager_input_write);
|
||||
|
||||
/* register the notification device */
|
||||
fusd_simple_register("/dev/pager/notify", "pager", "notify", 0666, NULL,
|
||||
fusd_simple_register("/dev/pager/notify", "pager", "pager!notify", 0666, NULL,
|
||||
open: pager_notify_open,
|
||||
close: pager_notify_close,
|
||||
read: pager_notify_read,
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
* not be read by anyone other than the driver owner (not even root!).
|
||||
* When you read from the device, it returns your PID to you.
|
||||
*
|
||||
* $Id: uid-filter.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -81,7 +81,7 @@ struct fusd_file_operations {
|
||||
int (*ioctl) (struct fusd_file_info *file, int request, void *data);
|
||||
int (*poll_diff) (struct fusd_file_info *file, unsigned int cached_state);
|
||||
int (*unblock) (struct fusd_file_info *file);
|
||||
int (*mmap) (struct fusd_file_info *file, int offset, size_t length, int flags, void** addr, size_t* out_length);
|
||||
int (*mmap) (struct fusd_file_info *file, int offset, size_t length, int prot, int flags, void** addr, size_t* out_length);
|
||||
} fusd_file_operations_t;
|
||||
|
||||
|
||||
|
||||
@ -81,6 +81,8 @@
|
||||
/* other constants */
|
||||
#define FUSD_MSG_MAGIC 0x7a6b93cd
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/* user->kernel: register a device */
|
||||
typedef struct {
|
||||
char name[FUSD_MAX_NAME_LENGTH+1];
|
||||
@ -96,7 +98,7 @@ typedef struct {
|
||||
pid_t pid;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
unsigned int flags; /* flags from file struct */
|
||||
unsigned long flags; /* flags from file struct */
|
||||
void *device_info; /* device info */
|
||||
void *private_info; /* file info */
|
||||
|
||||
@ -104,10 +106,15 @@ typedef struct {
|
||||
* union but it just makes things too complex and doesn't save all
|
||||
* that much memory anyway */
|
||||
ssize_t retval;
|
||||
size_t length;
|
||||
loff_t offset;
|
||||
unsigned long length;
|
||||
unsigned long offset;
|
||||
unsigned int cmd; /* ioctl cmd, poll_diff cached_state */
|
||||
|
||||
/* mmap parameters */
|
||||
unsigned long mmprot;
|
||||
unsigned long mmflags;
|
||||
unsigned long mmoffset;
|
||||
|
||||
union {
|
||||
unsigned long arg; /* ioctl */
|
||||
void *ptr_arg;
|
||||
@ -148,4 +155,6 @@ typedef struct {
|
||||
int num_open;
|
||||
} fusd_status_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif /* __FUSD_MSG_H__ */
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
*
|
||||
* Private header file used by the Linux Kernel Module
|
||||
*
|
||||
* $Id: kfusd.h 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#ifndef __KFUSD_H__
|
||||
@ -152,30 +151,6 @@ struct fusd_dev_t_s {
|
||||
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 ****/
|
||||
|
||||
# ifdef CONFIG_FUSD_USE_WAKEUPSYNC
|
||||
|
||||
@ -5,11 +5,11 @@ else
|
||||
KDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
PWD := $(shell pwd)
|
||||
ROOTFS ?=
|
||||
|
||||
GIT_DESCRIBE = $(shell git describe --dirty --tags)
|
||||
KERNEL_VER ?= 2.6.32.7
|
||||
|
||||
default:
|
||||
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS=-I$(PWD)/../include modules
|
||||
$(MAKE) -C $(KDIR) M=$(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
|
||||
|
||||
4153
kfusd/kfusd.c
4153
kfusd/kfusd.c
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
SRC = libfusd.c
|
||||
OBJ = libfusd.o
|
||||
TARGETS = libfusd.a libfusd.so.0.0
|
||||
GIT_DESCRIBE = $(shell git describe --dirty --tags)
|
||||
|
||||
default: $(TARGETS)
|
||||
|
||||
@ -15,7 +16,7 @@ clean:
|
||||
rm -f *.o *.so *.so.* *.a *.d *.d.* gmon.out *~
|
||||
|
||||
$(TARGETS):
|
||||
$(MAKE) target CFLAGS='-g -O2 $(SCF) $(GCF)'
|
||||
$(MAKE) target CFLAGS='-g -O2 $(SCF) $(GCF) -DGIT_DESCRIBE=\"${GIT_DESCRIBE}\"'
|
||||
|
||||
target: $(OBJ)
|
||||
$(LD) $(OBJ) $(SOLDFLAGS) -o libfusd.so.0.0 $(SLF)
|
||||
|
||||
@ -35,10 +35,9 @@
|
||||
*
|
||||
* authors: jelson and girod
|
||||
*
|
||||
* $Id: libfusd.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
char libfusd_c_id[] = "$Id: libfusd.c 12351 2007-01-19 07:22:54Z xiphmont $";
|
||||
char libfusd_c_id[] = "libfusd.c - FUSD " GIT_DESCRIBE;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -504,8 +503,8 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
||||
//printf("FUSD_MMAP\n");
|
||||
if (fops && fops->mmap)
|
||||
{
|
||||
user_retval = fops->mmap(file, msg->parm.fops_msg.offset, msg->parm.fops_msg.length, msg->parm.fops_msg.flags,
|
||||
&msg->parm.fops_msg.arg.ptr_arg, &msg->parm.fops_msg.length);
|
||||
user_retval = fops->mmap(file, msg->parm.fops_msg.mmoffset, msg->parm.fops_msg.length, msg->parm.fops_msg.mmprot,
|
||||
msg->parm.fops_msg.mmflags, &msg->parm.fops_msg.arg.ptr_arg, &msg->parm.fops_msg.length);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user