shithub: drawterm

Download patch

ref: 0a8a66a42a7aa9d1dabcc3956a48bfa5436ecbb9
parent: 47ee1007a90fef61a3af44ce6f00eb623720b80a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Feb 21 14:37:46 EST 2016

devfs-posix: use stat->st_dev<<32 | stat->st_ino for qid.path

--- a/kern/devfs-posix.c	Sat Feb 20 22:04:10 2016
+++ b/kern/devfs-posix.c	Sun Feb 21 14:37:46 2016
@@ -40,7 +40,7 @@
 
 char	*base = "/";
 
-static	Qid	fsqid(char*, struct stat *);
+static	Qid	fsqid(struct stat *);
 static	void	fspath(Chan*, char*, char*);
 static	ulong	fsdirread(Chan*, uchar*, int, ulong);
 static	int	fsomode(int);
@@ -130,7 +130,7 @@
 	uif->uid = stbuf.st_uid;
 	uif->gid = stbuf.st_gid;
 
-	c->qid = fsqid(path, &stbuf);
+	c->qid = fsqid(&stbuf);
 
 	return 1;
 }
@@ -302,7 +302,7 @@
 
 	if(stat(path, &stbuf) < 0)
 		error(strerror(errno));
-	c->qid = fsqid(path, &stbuf);
+	c->qid = fsqid(&stbuf);
 	c->offset = 0;
 	c->flag |= COPEN;
 	c->mode = openmode(mode);
@@ -458,31 +458,15 @@
 }
 
 static Qid
-fsqid(char *p, struct stat *st)
+fsqid(struct stat *st)
 {
 	Qid q;
-	int dev;
-	ulong h;
-	static int nqdev;
-	static uchar *qdev;
-
-	if(qdev == 0)
-		qdev = mallocz(65536U, 1);
 
 	q.type = 0;
 	if((st->st_mode&S_IFMT) ==  S_IFDIR)
 		q.type = QTDIR;
 
-	dev = st->st_dev & 0xFFFFUL;
-	if(qdev[dev] == 0)
-		qdev[dev] = ++nqdev;
-
-	h = 0;
-	while(*p != '\0')
-		h += *p++ * 13;
-	
-	q.path = (vlong)qdev[dev]<<32;
-	q.path |= h;
+	q.path = (uvlong)st->st_dev<<32 | st->st_ino;
 	q.vers = st->st_mtime;
 
 	return q;
@@ -579,7 +563,7 @@
 		d.uid = "unknown";
 		d.gid = "unknown";
 		d.muid = "unknown";
-		d.qid = fsqid(path, &stbuf);
+		d.qid = fsqid(&stbuf);
 		d.mode = (d.qid.type<<24)|(stbuf.st_mode&0777);
 		d.atime = stbuf.st_atime;
 		d.mtime = stbuf.st_mtime;