Skip to content

Commit 45778c6

Browse files
committed
tons of fixes and support for new stuff
1 parent deb861e commit 45778c6

File tree

12 files changed

+767
-418
lines changed

12 files changed

+767
-418
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
export MACOSX_DEPLOYMENT_TARGET=10.5
2-
export ARCHS=-arch i386 -arch x86_64 -arch ppc
2+
export ARCHS=-arch i386 -arch x86_64 #-arch ppc
33
export SYSROOT=/Developer/SDKs/MacOSX10.6.sdk
4-
export WARNINGS=-Wall -Wmost -Wextra -Wno-missing-braces -Wno-trigraphs #-Werror
5-
export CFLAGS=-isysroot $(SYSROOT) $(WARNINGS) -g
6-
export LFLAGS=-isysroot $(SYSROOT)
4+
export WARNINGS=-Wall -Wmost -Wextra -Wno-missing-braces -Wno-trigraphs -Werror
5+
export CFLAGS=-g -isysroot $(SYSROOT) $(WARNINGS)
6+
export LFLAGS=-g -isysroot $(SYSROOT)
77
export CC=gcc-4.2
8+
export CC=clang
89

910
DIRS=kext load mount plugin inst
1011

inst/InstallationCheck

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
KEXT=com.lab-fgb.kext.9p
4+
if /usr/sbin/kextstat -b $KEXT -l | grep -q $KEXT; then
5+
/sbin/kextunload -b $KEXT > /dev/null 2>&1 || exit 112
6+
fi
7+
exit 0

inst/InstallationCheck.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"16" = "There are 9P volumes currently in use. Unmount them and try again.";

inst/License.rtf

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
1+
{\rtf1\ansi\ansicpg1252\cocoartf1138
22
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
33
{\colortbl;\red255\green255\blue255;}
44
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
55
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
6-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
6+
\viewkind0
7+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
78

89
\f0\b\fs24 \cf0 Mac9P
910
\b0 is a package developed by Federico G. Benavento and is covered under the following BSD license:\
1011
\
1112
Copyright (c) 2011 by Federico G. Benavento.\
12-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
13+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640
1314
\cf0 All rights reserved.\
1415
\
1516
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\
16-
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural
17+
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720
1718
\ls1\ilvl0\cf0 {\listtext \'95 }Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\
1819
{\listtext \'95 }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.\
1920
{\listtext \'95 }Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\
20-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
21+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640
2122
\cf0 \
2223
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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\
23-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
24+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
2425
\cf0 \
25-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
26+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640
2627
\cf0 \
27-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
28-
\cf0 Portions of this package were derived from u9fs and which is distributed under the following license:\
28+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
29+
\cf0 Portions of this package were derived from u9fs which is distributed under the following license:\
2930
\
3031
The authors of this software are Bob Flandrena, Ken Thompson, Rob Pike, and Russ Cox.\
3132
\

inst/Makefile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ PKGRESDIR=$(PKG)/Contents/Resources
1111
PKGRESFILES=\
1212
License.rtf\
1313
Welcome.rtf\
14+
InstallationCheck\
15+
InstallationCheck.strings\
1416
# background.tiff\
1517
1618
PKGDEP=\
1719
../kext/9p\
1820
../mount/mount_9p\
1921
../load/load_9p\
2022
../plugin/9p\
23+
FSInfo.plist\
24+
KEInfo.plist\
25+
NPInfo.plist\
2126
$(PKGRESFILES)
2227

2328
all: pkg dmg
@@ -34,14 +39,19 @@ $(PKG): $(PKGDEP)
3439
cp -pX FSInfo.plist $(FSDIR)/Contents/Info.plist
3540
mkdir -p $(FSDIR)/Contents/Resources
3641
cp -pX ../mount/mount_9p $(FSDIR)/Contents/Resources
37-
# mkdir -p $(NPDIR)/Contents
38-
# cp -pX NPInfo.plist $(NPDIR)/Contents/Info.plist
39-
# mkdir -p $(NPDIR)/Contents/MacOS
40-
# cp -pX ../plugin/9p $(NPDIR)/Contents/MacOS/9p
42+
mkdir -p $(NPDIR)/Contents
43+
cp -pX NPInfo.plist $(NPDIR)/Contents/Info.plist
44+
mkdir -p $(NPDIR)/Contents/MacOS
45+
cp -pX ../plugin/9p $(NPDIR)/Contents/MacOS/9p
4146
sudo chown -R root:wheel $(PKGROOT)
4247
sudo chmod u+s $(KEDIR)/Contents/Resources/load_9p
43-
/Developer/usr/bin/packagemaker --root $(PKGROOT) --id com.lab-fgb.9p \
44-
--domain system --no-recommend --root-volume-only --out $@
48+
/Developer/usr/bin/packagemaker \
49+
--root $(PKGROOT) \
50+
--id com.lab-fgb.9p \
51+
--domain system \
52+
--no-recommend \
53+
--root-volume-only \
54+
--out $@
4555
cp -pX $(PKGRESFILES) $(PKGRESDIR)
4656
sudo rm -fr $(PKGROOT)
4757

@@ -53,11 +63,11 @@ $(DMG): $(PKG) #volume.icns
5363
cp -pRX $(PKG) $(VOLUME)
5464
# cp -pX volume.icns $(VOLUME)/.VolumeIcon.icns
5565
# /Developer/usr/bin/SetFile -a -C $(VOLUME)
56-
# ln -s $(VOLUME)/$(PKGRESDIR)/License.rtf $(VOLUME)/License.rtf
66+
ln -s $(VOLUME)/$(PKGRESDIR)/License.rtf $(VOLUME)/License.rtf
5767
cp -pX Uninstall.tool $(VOLUME)
5868
# cp -pX DS_Store $(VOLUME)/.DS_Store
5969
hdiutil detach -quiet $(VOLUME)
60-
hdiutil convert -quiet -format UDZO -imagekey zlib-level=9 $(TDMG) -o /tmp/$@
70+
hdiutil convert -quiet -format UDBZ $(TDMG) -o /tmp/$@
6171
mv -f /tmp/$@ $@
6272
rm -f $(TDMG)
6373

kext/9p.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ typedef struct {
4444
#include <sys/dirent.h>
4545
#include <sys/socket.h>
4646
#include <sys/random.h>
47+
#include <sys/ubc.h>
4748
#include <sys/un.h>
4849
#include <netinet/in.h>
4950
#include <netinet/tcp.h>
@@ -89,6 +90,9 @@ typedef uint32_t fid_9p;
8990
enum {
9091
NODE_INIT = 1<<0,
9192
NODE_WAITINIT = 1<<1,
93+
NODE_RECL = 1<<2,
94+
NODE_WAITRECL = 1<<3,
95+
NODE_MMAPPED = 1<<4,
9296
};
9397

9498
typedef enum {
@@ -106,17 +110,17 @@ struct node_9p {
106110
LIST_ENTRY(node_9p) next;
107111
mount_9p *nmp;
108112
vnode_t vp;
109-
fid_9p fid;
110-
qid_9p qid;
111-
112-
time_t dirtimer;
113-
dir_9p *dir;
114113

115114
lck_rw_t *lck;
116115
lcktype_9p lcktype;
117-
int flags;
116+
uint32_t flags;
118117
uint32_t iounit;
118+
fid_9p fid;
119+
dir_9p dir;
120+
time_t dirtimer;
119121
openfid_9p openfid[3]; /* rd, wr, rdwr */
122+
dir_9p *direntries;
123+
uint32_t ndirentries;
120124
};
121125

122126
/* socket flags */
@@ -155,7 +159,7 @@ struct mount_9p {
155159
fid_9p nfid;
156160
uint16_t ntag;
157161

158-
uint8_t rpcbuf[1024];
162+
uint8_t rpcbuf[MAXMSG];
159163

160164
/* reqs */
161165
TAILQ_HEAD(hreq_9p, req_9p) req;
@@ -171,31 +175,30 @@ struct mount_9p {
171175
__private_extern__ int authp9any_9p(mount_9p*, fid_9p, struct sockaddr*, char*, char*);
172176

173177
/* proto.c */
174-
__private_extern__ int version_9p(mount_9p*, char*, uint32_t, char**, uint32_t*);
178+
__private_extern__ int version_9p(mount_9p*, char*, char**);
175179
__private_extern__ int auth_9p(mount_9p*, char*, char*, fid_9p*, qid_9p*);
176180
__private_extern__ int attach_9p(mount_9p*, char*, char*, fid_9p, fid_9p*, qid_9p*);
177181
__private_extern__ int walk_9p(mount_9p*, fid_9p, char*, int, fid_9p*, qid_9p*);
178182
__private_extern__ int open_9p(mount_9p*, fid_9p, uint8_t, qid_9p*, uint32_t*);
179183
__private_extern__ int create_9p(mount_9p*, fid_9p, char*, int, uint8_t, uint32_t, qid_9p*, uint32_t*);
180-
__private_extern__ int read_9p(mount_9p*, fid_9p, void*, int, off_t, int*);
181-
__private_extern__ int write_9p(mount_9p*, fid_9p, void*, int, off_t, int*);
184+
__private_extern__ int read_9p(mount_9p*, fid_9p, void*, uint32_t, uint64_t, uint32_t*);
185+
__private_extern__ int write_9p(mount_9p*, fid_9p, void*, uint32_t, uint64_t, uint32_t*);
182186
__private_extern__ int clunk_9p(mount_9p*, fid_9p);
183187
__private_extern__ int remove_9p(mount_9p*, fid_9p);
184188
__private_extern__ int stat_9p(mount_9p*, fid_9p, dir_9p**);
185189
__private_extern__ int wstat_9p(mount_9p*, fid_9p, dir_9p*);
186-
__private_extern__ int readdir_9p(mount_9p*, fid_9p, off_t, dir_9p**, int*, int*);
190+
__private_extern__ int readdirs_9p(mount_9p*, fid_9p, dir_9p**, uint32_t*);
187191

188192
/* socket.c */
189193
__private_extern__ int connect_9p(mount_9p*, struct sockaddr*);
190194
__private_extern__ void disconnect_9p(mount_9p*);
191195
__private_extern__ int recvn_9p(socket_t, void*, size_t);
192196
__private_extern__ int sendn_9p(socket_t, void*, size_t);
193-
__private_extern__ int setbufsize_9p(mount_9p*);
194197
__private_extern__ int rpc_9p(mount_9p*, Fcall*, Fcall*, void**);
195198
__private_extern__ void cancelrpcs_9p(mount_9p*);
196199

197200
/* vfsops.c */
198-
__private_extern__ void* malloc_9p(uint32_t);
201+
__private_extern__ void* malloc_9p(size_t);
199202
__private_extern__ void free_9p(void*);
200203

201204
/* vnops.c */
@@ -208,7 +211,9 @@ __private_extern__ lck_grp_t *lck_grp_9p;
208211
#define MTO9P(m) ((mount_9p*)vfs_fsprivate(m))
209212
#define NTO9P(vp) ((node_9p*)vnode_fsnode(vp))
210213
#define QTOI(q) (q.path | ((uint64_t)q.type<<56))
211-
#define TRACE() printf("%d: %s...\n", proc_selfpid(), __FUNCTION__)
214+
#define ITOP(i) ((i)&0xFF0000000000)
215+
#define ITOT(i) ((i)>>56)
216+
#define TRACE() //printf("%d: %s...\n", proc_selfpid(), __FUNCTION__)
212217
#define DEBUG(f, a...) printf("%d: %s: "f"\n", proc_selfpid(), __FUNCTION__, ## a)
213218

214219
#endif /* KERNEL */

kext/auth.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,14 @@ gettickets(struct sockaddr *sa, char *trbuf, char *tbuf)
263263
}
264264

265265
static int
266-
p9sk1(mount_9p* nmp, fid_9p afid, struct sockaddr *addr, char *uname, char *akey, off_t off)
266+
p9sk1(mount_9p* nmp, fid_9p afid, struct sockaddr *addr, char *uname, char *akey, uint64_t off)
267267
{
268268
char cchal[CHALLEN], *tbuf, *trbuf;
269-
int e, l;
269+
uint32_t l;
270270
Authenticator auth;
271271
Ticketreq tr;
272272
Ticket t;
273+
int e;
273274

274275
TRACE();
275276
tbuf = malloc_9p(TICKETLEN+TICKETLEN+AUTHENTLEN);
@@ -296,7 +297,7 @@ p9sk1(mount_9p* nmp, fid_9p afid, struct sockaddr *addr, char *uname, char *akey
296297
goto error;
297298
}
298299

299-
DEBUG("authdom: %s", tr.authdom);
300+
// DEBUG("authdom: %s", tr.authdom);
300301

301302
tr.type = AuthTreq;
302303
bcopy(uname, tr.hostid, NAMELEN);
@@ -359,8 +360,9 @@ __private_extern__ int
359360
authp9any_9p(mount_9p *nmp, fid_9p afid, struct sockaddr *addr, char *uname, char *akey)
360361
{
361362
char *buf, *buf2, *dom, *p, *q;
362-
off_t off;
363-
int e, n, l, v2;
363+
uint32_t n, l;
364+
uint64_t off;
365+
int e, v2;
364366

365367
TRACE();
366368
buf = malloc_9p(BSIZ);
@@ -373,7 +375,7 @@ authp9any_9p(mount_9p *nmp, fid_9p afid, struct sockaddr *addr, char *uname, cha
373375

374376
off += l;
375377
buf[l] = '\0';
376-
DEBUG("%s", buf);
378+
// DEBUG("%s", buf);
377379
v2 = 0;
378380
p = buf;
379381
if (strncmp(p, "v.2 ", 4) == 0) {

0 commit comments

Comments
 (0)