Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtfs #1

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a520819
Import lib9p from https://github.com/jceel/lib9p
Feb 1, 2016
1f0dd18
Add lib9p to the build.
Feb 1, 2016
dda24d8
Add initial implementation of virtio-9p device.
Feb 1, 2016
88b87df
Fix typo.
Feb 1, 2016
35814c5
Import qid fix from lib9p repo.
Feb 1, 2016
8ede000
Import Tattach fix from lib9p repo.
Feb 2, 2016
b57bc34
Import 9P2000 and rmdir fixes from lib9p repo.
Feb 6, 2016
3e47391
Report configuration registers size properly.
Feb 11, 2016
33c3cd7
Remove unneeded DEBUG_FLAGS variable.
Feb 11, 2016
ea7f1bd
Sync with lib9p master (adds 9p2000.L support and lots of fixes).
Jun 12, 2016
89840c3
Merge remote-tracking branch 'upstream/master' into virtfs
Jun 12, 2016
3be9564
Merge remote-tracking branch 'upstream/master' into virtfs
jceel Oct 13, 2018
6cc6949
Add rfuncs.c to the build.
jceel Oct 13, 2018
0957e0a
Update to lib9p @ 01565f940e38e289dd5b29444170a165b5ccf537
jceel Oct 15, 2018
d2d9b23
Adjust lib9p makefile to build the imported version of the library.
jceel Oct 15, 2018
55a77f6
Add capabilities support to virtio-9p.
jceel Oct 15, 2018
eccb686
Update to lib9p @ 52834b14c2754e1f168fd2b907e6a83617ada9ed
Dec 24, 2018
e25496d
Import lib9p @ 7ee92e7a690e727e661e1f62975a7fb7355b18fb
Dec 25, 2018
82f1098
Add lib9p include dir to mtree.
Dec 25, 2018
2bdf84d
Enable Casper in lib9p.
Dec 26, 2018
f192aee
Merge remote-tracking branch 'upstream/master' into virtfs
Dec 27, 2018
4db81f7
Remove debug CFLAGS from the Makefile.
Dec 27, 2018
520469a
Fix mismerge, add DEBUG_FLAGS for lib9p.
Dec 27, 2018
8002d62
Update copyright notice.
Dec 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions contrib/lib9p/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Object files
*.o
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
/build/

*.po
*.pico
*.depend
47 changes: 47 additions & 0 deletions contrib/lib9p/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Copyright 2016 Jakub Klama <[email protected]>
All rights reserved

Redistribution and use in source and binary forms, with or without
modification, are permitted providing that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.

Some parts of the code are based on libixp (http://libs.suckless.org/libixp)
library code released under following license:

© 2005-2006 Anselm R. Garbe <[email protected]>
© 2006-2010 Kris Maglione <maglione.k at Gmail>

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
76 changes: 76 additions & 0 deletions contrib/lib9p/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
CC_VERSION := $(shell $(CC) --version | \
sed -n -e '/clang-/s/.*clang-\([0-9][0-9]*\).*/\1/p')
ifeq ($(CC_VERSION),)
# probably not clang
CC_VERSION := 0
endif

WFLAGS :=

# Warnings are version-dependent, unfortunately,
# so test for version before adding a -W flag.
# Note: gnu make requires $(shell test ...) for "a > b" type tests.
ifeq ($(shell test $(CC_VERSION) -gt 0; echo $$?),0)
WFLAGS += -Weverything
WFLAGS += -Wno-padded
WFLAGS += -Wno-gnu-zero-variadic-macro-arguments
WFLAGS += -Wno-format-nonliteral
WFLAGS += -Wno-unused-macros
WFLAGS += -Wno-disabled-macro-expansion
WFLAGS += -Werror
endif

ifeq ($(shell test $(CC_VERSION) -gt 600; echo $$?),0)
WFLAGS += -Wno-reserved-id-macro
endif

CFLAGS := $(WFLAGS) \
-g \
-O0 \
-DL9P_DEBUG=L9P_DEBUG
# Note: to turn on debug, use -DL9P_DEBUG=L9P_DEBUG,
# and set env variable LIB9P_LOGGING to stderr or to
# the (preferably full path name of) the debug log file.

LIB_SRCS := \
pack.c \
connection.c \
request.c \
genacl.c \
log.c \
hashtable.c \
utils.c \
rfuncs.c \
threadpool.c \
sbuf/sbuf.c \
transport/socket.c \
backend/fs.c

SERVER_SRCS := \
example/server.c

BUILD_DIR := build
LIB_OBJS := $(addprefix build/,$(LIB_SRCS:.c=.o))
SERVER_OBJS := $(SERVER_SRCS:.c=.o)
LIB := lib9p.dylib
SERVER := server

all: build $(LIB) $(SERVER)

$(LIB): $(LIB_OBJS)
cc -dynamiclib $^ -o build/$@

$(SERVER): $(SERVER_OBJS) $(LIB)
cc $< -o build/$(SERVER) -Lbuild/ -l9p

clean:
rm -rf build
rm -f $(SERVER_OBJS)
build:
mkdir build
mkdir build/sbuf
mkdir build/transport
mkdir build/backend

build/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
27 changes: 27 additions & 0 deletions contrib/lib9p/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Note: to turn on debug, use -DL9P_DEBUG=L9P_DEBUG,
# and set env variable LIB9P_LOGGING to stderr or to
# the (preferably full path name of) the debug log file.

LIB= 9p
SHLIB_MAJOR= 1
SRCS= pack.c \
connection.c \
request.c log.c \
hashtable.c \
genacl.c \
utils.c \
rfuncs.c \
threadpool.c \
transport/socket.c \
backend/fs.c

INCS= lib9p.h
CC= clang
CFLAGS= -g -O0 -DL9P_DEBUG=L9P_DEBUG -DWITH_CASPER
LIBADD= sbuf libcasper libcap_pwd libcap_grp
SUBDIR= example

cscope: .PHONY
cd ${.CURDIR}; cscope -buq $$(find . -name '*.[ch]' -print)

.include <bsd.lib.mk>
20 changes: 20 additions & 0 deletions contrib/lib9p/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# lib9p

lib9p is a server library implementing 9p2000, 9p2000.u and 9p2000.L revisions
of 9P protocol. It is being developed primarily as a backend for virtio-9p in
BHyVe, the FreeBSD hypervisor.

# Features

* 9p2000, 9p2000.u and 9p2000.L protocol support
* Built-in TCP transport

# Supported operating systems

* FreeBSD (>=10)
* macOS (>=10.9)

# Authors

* Jakub Klama [jceel](https://github.com/jceel)
* Chris Torek [chris3torek](https://github.com/chris3torek)
27 changes: 27 additions & 0 deletions contrib/lib9p/apple_endian.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef _APPLE_ENDIAN_H
#define _APPLE_ENDIAN_H

/*
* Shims to make Apple's endian headers and macros compatible
* with <sys/endian.h> (which is awful).
*/

# include <libkern/OSByteOrder.h>

# define _LITTLE_ENDIAN 0x12345678
# define _BIG_ENDIAN 0x87654321

# ifdef __LITTLE_ENDIAN__
# define _BYTE_ORDER _LITTLE_ENDIAN
# endif
# ifdef __BIG_ENDIAN__
# define _BYTE_ORDER _BIG_ENDIAN
# endif

# define htole32(x) OSSwapHostToLittleInt32(x)
# define le32toh(x) OSSwapLittleToHostInt32(x)

# define htobe32(x) OSSwapHostToBigInt32(x)
# define be32toh(x) OSSwapBigToHostInt32(x)

#endif /* _APPLE_ENDIAN_H */
69 changes: 69 additions & 0 deletions contrib/lib9p/backend/backend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2016 Jakub Klama <[email protected]>
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
*/


#ifndef LIB9P_BACKEND_H
#define LIB9P_BACKEND_H

struct l9p_backend {
void *softc;
void (*freefid)(void *, struct l9p_fid *);
int (*attach)(void *, struct l9p_request *);
int (*clunk)(void *, struct l9p_fid *);
int (*create)(void *, struct l9p_request *);
int (*open)(void *, struct l9p_request *);
int (*read)(void *, struct l9p_request *);
int (*remove)(void *, struct l9p_fid *);
int (*stat)(void *, struct l9p_request *);
int (*walk)(void *, struct l9p_request *);
int (*write)(void *, struct l9p_request *);
int (*wstat)(void *, struct l9p_request *);
int (*statfs)(void *, struct l9p_request *);
int (*lopen)(void *, struct l9p_request *);
int (*lcreate)(void *, struct l9p_request *);
int (*symlink)(void *, struct l9p_request *);
int (*mknod)(void *, struct l9p_request *);
int (*rename)(void *, struct l9p_request *);
int (*readlink)(void *, struct l9p_request *);
int (*getattr)(void *, struct l9p_request *);
int (*setattr)(void *, struct l9p_request *);
int (*xattrwalk)(void *, struct l9p_request *);
int (*xattrcreate)(void *, struct l9p_request *);
int (*xattrread)(void *, struct l9p_request *);
int (*xattrwrite)(void *, struct l9p_request *);
int (*xattrclunk)(void *, struct l9p_fid *);
int (*readdir)(void *, struct l9p_request *);
int (*fsync)(void *, struct l9p_request *);
int (*lock)(void *, struct l9p_request *);
int (*getlock)(void *, struct l9p_request *);
int (*link)(void *, struct l9p_request *);
int (*mkdir)(void *, struct l9p_request *);
int (*renameat)(void *, struct l9p_request *);
int (*unlinkat)(void *, struct l9p_request *);
};

#endif /* LIB9P_BACKEND_H */
Loading