Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Dec 2003 00:31:59 +0100 (CET)
From:      Christian Laursen <xi@borderworlds.dk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/60242: New port: A server for the linux network block device (nbd) 
Message-ID:  <20031214233159.294BBB823@borg.borderworlds.dk>
Resent-Message-ID: <200312142340.hBENeDa4069947@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         60242
>Category:       ports
>Synopsis:       New port: A server for the linux network block device (nbd)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 14 15:40:13 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Christian Laursen
>Release:        FreeBSD 5.2-RC i386
>Organization:
The Border Worlds 
>Environment:
System: FreeBSD borg.borderworlds.dk 5.2-RC FreeBSD 5.2-RC #13: Sun Dec 7 20:25:02 CET 2003 root@borg.borderworlds.dk:/usr/obj/usr/src/sys/BORG i386


	
>Description:
This is a server for the linux network block device (nbd). It allows linux to
use a partition or a file over the network as a regular block device.
	
>How-To-Repeat:
	
>Fix:

	

--- nbd-server.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	nbd-server
#	nbd-server/files
#	nbd-server/files/nbd.h
#	nbd-server/files/patch-include
#	nbd-server/distinfo
#	nbd-server/Makefile
#	nbd-server/pkg-descr
#	nbd-server/pkg-plist
#
echo c - nbd-server
mkdir -p nbd-server > /dev/null 2>&1
echo c - nbd-server/files
mkdir -p nbd-server/files > /dev/null 2>&1
echo x - nbd-server/files/nbd.h
sed 's/^X//' >nbd-server/files/nbd.h << 'END-of-nbd-server/files/nbd.h'
X/*
X * 1999 Copyright (C) Pavel Machek, pavel@ucw.cz. This code is GPL.
X * 1999/11/04 Copyright (C) 1999 VMware, Inc. (Regis "HPReg" Duchesne)
X *            Made nbd_end_request() use the io_request_lock
X * 2001 Copyright (C) Steven Whitehouse
X *            New nbd_end_request() for compatibility with new linux block
X *            layer code.
X */
X
X#ifndef LINUX_NBD_H
X#define LINUX_NBD_H
X
X#define NBD_SET_SOCK	_IO( 0xab, 0 )
X#define NBD_SET_BLKSIZE	_IO( 0xab, 1 )
X#define NBD_SET_SIZE	_IO( 0xab, 2 )
X#define NBD_DO_IT	_IO( 0xab, 3 )
X#define NBD_CLEAR_SOCK	_IO( 0xab, 4 )
X#define NBD_CLEAR_QUE	_IO( 0xab, 5 )
X#define NBD_PRINT_DEBUG	_IO( 0xab, 6 )
X#define NBD_SET_SIZE_BLOCKS	_IO( 0xab, 7 )
X#define NBD_DISCONNECT  _IO( 0xab, 8 )
X
X#ifdef MAJOR_NR
X
X#include <linux/locks.h>
X#include <asm/semaphore.h>
X
X#define LOCAL_END_REQUEST
X
X#include <linux/blk.h>
X
X#ifdef PARANOIA
Xextern int requests_in;
Xextern int requests_out;
X#endif
X
Xstatic void
Xnbd_end_request(struct request *req)
X{
X	struct buffer_head *bh;
X	unsigned nsect;
X	unsigned long flags;
X	int uptodate = (req->errors == 0) ? 1 : 0;
X
X#ifdef PARANOIA
X	requests_out++;
X#endif
X	spin_lock_irqsave(&io_request_lock, flags);
X	while((bh = req->bh) != NULL) {
X		nsect = bh->b_size >> 9;
X		blk_finished_io(nsect);
X		req->bh = bh->b_reqnext;
X		bh->b_reqnext = NULL;
X		bh->b_end_io(bh, uptodate);
X	}
X	blkdev_release_request(req);
X	spin_unlock_irqrestore(&io_request_lock, flags);
X}
X
X#define MAX_NBD 128
X
Xstruct nbd_device {
X	int refcnt;	
X	int flags;
X	int harderror;		/* Code of hard error			*/
X#define NBD_READ_ONLY 0x0001
X#define NBD_WRITE_NOCHK 0x0002
X	struct socket * sock;
X	struct file * file; 		/* If == NULL, device is not ready, yet	*/
X	int magic;			/* FIXME: not if debugging is off	*/
X	spinlock_t queue_lock;
X	struct list_head queue_head;	/* Requests are added here...			*/
X	struct semaphore tx_lock;
X};
X#endif
X
X/* This now IS in some kind of include file...	*/
X
X/* These are send over network in request/reply magic field */
X
X#define NBD_REQUEST_MAGIC 0x25609513
X#define NBD_REPLY_MAGIC 0x67446698
X/* Do *not* use magics: 0x12560953 0x96744668. */
X
X/*
X * This is packet used for communication between client and
X * server. All data are in network byte order.
X */
Xstruct nbd_request {
X	u32 magic;
X	u32 type;	/* == READ || == WRITE 	*/
X	char handle[8];
X	u64 from;
X	u32 len;
X}
X#ifdef __GNUC__
X	__attribute__ ((packed))
X#endif
X;
X
Xstruct nbd_reply {
X	u32 magic;
X	u32 error;		/* 0 = ok, else error	*/
X	char handle[8];		/* handle you got from request	*/
X};
X#endif
END-of-nbd-server/files/nbd.h
echo x - nbd-server/files/patch-include
sed 's/^X//' >nbd-server/files/patch-include << 'END-of-nbd-server/files/patch-include'
Xdiff -urN nbd-2.6.orig/nbd-server.c nbd-2.6/nbd-server.c
X--- nbd-2.6.orig/nbd-server.c	Thu Oct 16 15:08:17 2003
X+++ nbd-server.c	Sun Dec 14 23:48:10 2003
X@@ -53,6 +53,7 @@
X #include <sys/stat.h>
X #include <sys/wait.h>		/* wait */
X #include <sys/ioctl.h>
X+#include <sys/param.h>
X #include <sys/mount.h>		/* For BLKGETSIZE */
X #include <signal.h>		/* sigaction */
X #include <netinet/tcp.h>
END-of-nbd-server/files/patch-include
echo x - nbd-server/distinfo
sed 's/^X//' >nbd-server/distinfo << 'END-of-nbd-server/distinfo'
XMD5 (nbd-2.6.0.tar.gz) = 97ee3120f321628b86f5c0fe77f89255
END-of-nbd-server/distinfo
echo x - nbd-server/Makefile
sed 's/^X//' >nbd-server/Makefile << 'END-of-nbd-server/Makefile'
X# New ports collection makefile for:   nbd-server
X# Date created:        14 december 2003
X# Whom:                Christian Laursen <xi@borderworlds.dk>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	nbd-server
XPORTVERSION=	2.6.0
XCATEGORIES=	net
XMASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
XMASTER_SITE_SUBDIR=	nbd
XDISTNAME=       nbd-${PORTVERSION}
X
XMAINTAINER=	xi@borderworlds.dk
XCOMMENT=	A server for the linux network block device (nbd)
X
XWRKSRC=		${WRKDIR}/nbd-2.6
X
XHAS_CONFIGURE=	yes
XCONFIGURE_ARGS+=	--prefix=${PREFIX}
XUSE_GMAKE=	yes
X
Xpost-extract:
X	${CP} ${FILESDIR}/nbd.h ${WRKSRC}
X
X.include <bsd.port.mk>
END-of-nbd-server/Makefile
echo x - nbd-server/pkg-descr
sed 's/^X//' >nbd-server/pkg-descr << 'END-of-nbd-server/pkg-descr'
XThis is a server for the linux network block device (nbd). It allows linux to
Xuse a partition or a file over the network as a regular block device.
X
XWWW: http://nbd.sourceforge.net/
X
X- Christian
Xxi@borderworlds.dk
END-of-nbd-server/pkg-descr
echo x - nbd-server/pkg-plist
sed 's/^X//' >nbd-server/pkg-plist << 'END-of-nbd-server/pkg-plist'
Xbin/nbd-server
END-of-nbd-server/pkg-plist
exit
--- nbd-server.shar ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031214233159.294BBB823>