--- p910nd-0.9.orig/p910nd.c
+++ p910nd-0.9/p910nd.c
@@ -95,7 +95,7 @@
 #ifdef		LOCKFILE_DIR
 #define		LOCKFILE	LOCKFILE_DIR "/p910%cd"
 #else
-#define		LOCKFILE	"/var/lock/subsys/p910%cd"
+#define		LOCKFILE	"/var/lock/p910%cd"
 #endif
 #define		PRINTERFILE	"/dev/lp%c"
 #define		LOGOPTS		LOG_ERR
@@ -355,14 +355,15 @@
 		/*write(fd, "Printing", 8);*/
 		
 		/* Make sure lp device is open... */
-		while (f == NULL) {
+		do {
 			f = open_printer(lpnumber);
-			sleep(10);
-		}
+		if (f == NULL) sleep(10);
+		} while (f == NULL);
 
 		if (copy_stream(fd, f) < 0)
 			syslog(LOGOPTS, "copy_stream: %m\n");
 		(void)close(fd);
+		(void)fclose(f);
 	}
 	syslog(LOGOPTS, "accept: %m\n");
 	free_lock();
--- p910nd-0.9.orig/debian/README.Debian
+++ p910nd-0.9/debian/README.Debian
@@ -0,0 +1,6 @@
+p910nd for Debian
+-----------------
+
+	http://etherboot.sourceforge.net/p910nd/
+
+ -- Kim-man 'Punky' TSE <punkytse@yahoo.com>  Thu, 19 Jul 2007 16:24:13 +0000
--- p910nd-0.9.orig/debian/changelog
+++ p910nd-0.9/debian/changelog
@@ -0,0 +1,6 @@
+p910nd (0.9-1) unstable; urgency=low
+
+  * Initial release 
+
+ -- Kim-man 'Punky' TSE <punkytse@yahoo.com>  Thu, 19 Jul 2007 16:24:13 +0000
+
--- p910nd-0.9.orig/debian/compat
+++ p910nd-0.9/debian/compat
@@ -0,0 +1 @@
+5
--- p910nd-0.9.orig/debian/dirs
+++ p910nd-0.9/debian/dirs
@@ -0,0 +1 @@
+usr/sbin
--- p910nd-0.9.orig/debian/patches/02-varlock
+++ p910nd-0.9/debian/patches/02-varlock
@@ -0,0 +1,12 @@
+@DPATCH@
+--- p910nd.orig/p910nd.c	2007-07-19 16:49:47.000000000 +0000
++++ p910nd/p910nd.c	2007-07-20 03:31:07.000000000 +0000
+@@ -95,7 +95,7 @@
+ #ifdef		LOCKFILE_DIR
+ #define		LOCKFILE	LOCKFILE_DIR "/p910%cd"
+ #else
+-#define		LOCKFILE	"/var/lock/subsys/p910%cd"
++#define		LOCKFILE	"/var/lock/p910%cd"
+ #endif
+ #define		PRINTERFILE	"/dev/lp%c"
+ #define		LOGOPTS		LOG_ERR
--- p910nd-0.9.orig/debian/patches/00list
+++ p910nd-0.9/debian/patches/00list
@@ -0,0 +1,2 @@
+01-crashfix
+02-varlock
--- p910nd-0.9.orig/debian/patches/01-crashfix
+++ p910nd-0.9/debian/patches/01-crashfix
@@ -0,0 +1,22 @@
+@DPATCH@
+--- p910nd-0.9.orig/p910nd.c      2007-04-11 02:25:53.000000000 +0000
++++ p910nd-0.9/p910nd.c    2007-06-30 19:33:56.407378748 +0000
+@@ -355,14 +355,15 @@
+ 		/*write(fd, "Printing", 8);*/
+ 
+ 		/* Make sure lp device is open... */
+-		while (f == NULL) {
++		do {
+ 			f = open_printer(lpnumber);
+-			sleep(10);
+-		}
++		if (f == NULL) sleep(10);
++		} while (f == NULL);
+ 
+		if (copy_stream(fd, f) < 0)
+ 			syslog(LOGOPTS, "copy_stream: %m\n");
+ 		(void)close(fd);
++		(void)fclose(f);
+ 	}
+ 	syslog(LOGOPTS, "accept: %m\n");
+ 	free_lock(); 
--- p910nd-0.9.orig/debian/init.d
+++ p910nd-0.9/debian/init.d
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# start/stop p910nd printserver daemon.
+
+### BEGIN INIT INFO
+# Provides:          p910nd
+# Required-Start:    $network $syslog
+# Required-Stop:     $network $syslog
+# Default-Start:     3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: p910nd a non-spooling printserver
+### END INIT INFO
+
+if [ -f /etc/default/p910nd ]; then
+  . /etc/default/p910nd
+elif [ -f /etc/p910nd.conf ]; then
+  . /etc/p910nd.conf
+fi
+
+# p910 uses a different process name for each port
+NAME=p910${P910ND_PORT}d
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/p910nd
+DESC="p910nd printserver"
+DAEMON=/usr/sbin/p910nd
+DAEMON_OPTS="-f $P910ND_DEV $P910ND_OPTS $P910ND_PORT"
+
+test -x $DAEMON || exit 0
+
+. /lib/lsb/init-functions
+
+# --- determine current status and correct if necessary the pidfile
+#     return state
+isrunning()
+{
+        procpid=`pidof $NAME`
+        if [ -n "$procpid" ] ; then     # process is running
+           pid=xx
+           [ -r $PIDFILE ] &&  pid=`cat $PIDFILE`
+           [ "$procpid" != "$pid" ] &&  echo "$procpid" >$PIDFILE
+           echo $procpid
+           return 1
+        else
+           [ -r $PIDFILE ] && rm -f $PIDFILE
+        fi
+        echo 0
+	return 0
+}
+
+
+case "$1" in
+  start)
+	log_daemon_msg "Starting $DESC" $NAME
+        pid=`isrunning`
+        if [ $pid -ne 0 ] ; then
+		log_begin_msg " is already started (pid=$pid)"
+		log_end_msg 0 
+	else
+		start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
+		log_end_msg $?
+	fi
+    ;;
+  stop)
+	log_daemon_msg "Stopping $DESC" $NAME
+        pid=`isrunning`
+        if [ $pid -eq 0 ] ; then
+		log_begin_msg " is already stopped"
+		log_end_msg 0 
+        else
+  		start-stop-daemon --quiet --stop --oknodo --pidfile $PIDFILE
+		log_end_msg $?
+	fi
+	[ -r $PIDFILE ] && rm -f $PIDFILE
+	;;
+  reload|restart|force-reload)
+	$0 stop
+	$0 start
+	;;
+  status)
+	log_action_begin_msg "Status $DESC" $NAME
+        pid=`isrunning`
+        [ $pid -ne 0 ] && log_action_msg " is running (pid=$pid)"
+        [ $pid -eq 0 ] && log_action_msg " is not running"
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
--- p910nd-0.9.orig/debian/copyright
+++ p910nd-0.9/debian/copyright
@@ -0,0 +1,22 @@
+This package was debianized by root <punkytse@yahoo.com> on
+Thu, 19 Jul 2007 16:24:13 +0000.
+
+It was downloaded from <fill in http/ftp site>
+
+Upstream Author: <put author(s) name and email here>
+
+Copyright: <put the year(s) of the copyright, and the names of the
+            copyright holder(s) here>
+
+License:
+
+<Put the license of the package here>
+
+
+The Debian packaging is (C) 2007, root <punkytse@yahoo.com> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
+
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
+
--- p910nd-0.9.orig/debian/control
+++ p910nd-0.9/debian/control
@@ -0,0 +1,12 @@
+Source: p910nd
+Section: unknown
+Priority: extra
+Maintainer: root <punkytse@yahoo.com>
+Build-Depends: debhelper (>= 5)
+Standards-Version: 3.7.2
+
+Package: p910nd
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: <insert up to 60 chars description>
+ <insert long description, indented with spaces>
--- p910nd-0.9.orig/debian/rules
+++ p910nd-0.9/debian/rules
@@ -0,0 +1,99 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+	# Add here commands to configure the package.
+
+	touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+	dh_testdir
+
+	# Add here commands to compile the package.
+	$(MAKE)
+	#docbook-to-man debian/p910nd.sgml > p910nd.1
+
+	touch $@
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+
+	# Add here commands to clean up after the build process.
+	-$(MAKE) clean
+
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs
+
+	# Add here commands to install the package into debian/p910nd.
+	#$(MAKE) DESTDIR=$(CURDIR)/debian/p910nd install
+	install -d $(CURDIR)/debian/p910nd/usr/sbin
+	install p910nd $(CURDIR)/debian/p910nd/usr/sbin
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs 
+	dh_installdocs
+	dh_installexamples
+#	dh_install
+#	dh_installmenu
+#	dh_installdebconf	
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_python
+	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+	dh_installman p910nd.8
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_perl
+#	dh_makeshlibs
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- p910nd-0.9.orig/debian/p910nd.default
+++ p910nd-0.9/debian/p910nd.default
@@ -0,0 +1,14 @@
+# Default settings for p910nd printerserver. 
+# This file is sourced by /bin/sh from /etc/init.d/p910nd.
+
+# --- specify the printer device
+P910ND_DEV=/dev/usb/lp0
+
+# --- specify listening port 0,1 or 2  (port 9100 - 9102)
+P910ND_PORT=0
+
+# --- specify additional options:
+#    -b      = bidirectional
+#    -i <ip> = bind to ip address
+P910ND_OPTS="-b"
+
