changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: ip/cifsd: add basic support for UNIX extensions

changeset 7384: cfe13a9d53a3
parent 7383: 22d364b65600
child 7385: 6e69acb02881
author: cinap_lenrek@felloff.net
date: Tue, 10 Sep 2019 21:19:34 +0200
files: sys/src/cmd/ip/cifsd/dat.h sys/src/cmd/ip/cifsd/smb.c
description: ip/cifsd: add basic support for UNIX extensions
     1.1--- a/sys/src/cmd/ip/cifsd/dat.h
     1.2+++ b/sys/src/cmd/ip/cifsd/dat.h
     1.3@@ -168,6 +168,7 @@ enum
     1.4 	CAP_NT_SMBS = 0x10,
     1.5 	CAP_NT_STATUS = 0x40,
     1.6 	CAP_NT_FIND = 0x200,
     1.7+	CAP_UNIX = 0x800000,
     1.8 
     1.9 	/* extended file attributes */
    1.10 	ATTR_READONLY = 0x1,
     2.1--- a/sys/src/cmd/ip/cifsd/smb.c
     2.2+++ b/sys/src/cmd/ip/cifsd/smb.c
     2.3@@ -63,7 +63,7 @@ err:
     2.4 	de = dom + smbstrpack16(d, d, d + sizeof(dom), domain);
     2.5 	if(!pack(r->rh, r->rp, r->re, "#0b{*2wbwwllllvw#2b}#1w{[][]}.",
     2.6 		x, mode, 50, 1, BUFFERSIZE, 0x10000, sessionkey,
     2.7-		CAP_UNICODE | CAP_LARGEFILES | 
     2.8+		CAP_UNIX | CAP_UNICODE | CAP_LARGEFILES | 
     2.9 		CAP_NT_FIND | CAP_NT_SMBS | CAP_NT_STATUS,
    2.10 		tofiletime(time(0)), -tzoff/60, c, ce, d, de, &r->rp))
    2.11 		goto err;
    2.12@@ -1013,6 +1013,22 @@ smbqueryinformationdisk(Req *r, uchar *h
    2.13 }
    2.14 
    2.15 static int
    2.16+unixuid(char *)
    2.17+{
    2.18+	return 99999;
    2.19+}
    2.20+static int
    2.21+unixgid(char *)
    2.22+{
    2.23+	return 99999;
    2.24+}
    2.25+static int
    2.26+unixtype(Dir *d)
    2.27+{
    2.28+	return (d->qid.type & QTDIR) != 0;
    2.29+}
    2.30+
    2.31+static int
    2.32 fpackdir(Req *r, Dir *d, Tree *t, int i, int level, uchar *b, uchar *p, uchar *e, uchar **prevoff, uchar **nameoff)
    2.33 {
    2.34 	vlong atime, mtime, alen, dlen;
    2.35@@ -1053,6 +1069,19 @@ fpackdir(Req *r, Dir *d, Tree *t, int i,
    2.36 			&namep, r->o->untermnamepack, d->name);
    2.37 		break;
    2.38 
    2.39+	case 0x0202:	/* SMB_FIND_FILE_UNIX */
    2.40+		n = pack(b, p, e, "llvvvvvvvlvvvvv.f",
    2.41+			0, i,
    2.42+			dlen, alen,
    2.43+			mtime, atime, mtime,
    2.44+			unixuid(d->uid), unixgid(d->gid), unixtype(d),
    2.45+			0, 0, /* MAJ/MIN */
    2.46+			d->qid.path,
    2.47+			d->mode & 0777,
    2.48+			1,	/* NLINKS */
    2.49+			&namep, r->o->namepack, d->name);
    2.50+		break;
    2.51+
    2.52 	default:
    2.53 		logit("[%.4x] unknown FIND infolevel", level);
    2.54 		return -1;
    2.55@@ -1107,6 +1136,15 @@ qpackdir(Req *, Dir *d, Tree *t, File *f
    2.56 			return 0;
    2.57 		return pack(b, p, e, "l#0lvv{f}", 0, dlen, alen, smbuntermstrpack16, "::$DATA");
    2.58 
    2.59+	case 0x0200:	/* SMB_QUERY_FILE_UNIX_BASIC */
    2.60+		return pack(b, p, e, "vvvvvvvlvvvvv",
    2.61+			dlen, alen,
    2.62+			mtime, atime, mtime,
    2.63+			unixuid(d->uid), unixgid(d->gid), unixtype(d),
    2.64+			0, 0, /* MAJ/MIN */
    2.65+			d->qid.path,
    2.66+			d->mode & 0777,
    2.67+			link);	/* NLINKS */
    2.68 	default:
    2.69 		logit("[%.4x] unknown QUERY infolevel", level);
    2.70 		return -1;
    2.71@@ -1381,6 +1419,10 @@ trans2queryfsinformation(Trans *t)
    2.72 			share->namelen, smbuntermstrpack16, share->fsname);
    2.73 		break;
    2.74 
    2.75+	case 0x0200:	/* SMB_QUERY_CIFS_UNIX_INFO */
    2.76+		n = pack(t->out.data.b, t->out.data.p, t->out.data.e, "wwv", 1, 0, 0x800000);
    2.77+		break;
    2.78+
    2.79 	default:
    2.80 		logit("[%.4x] unknown FS infolevel", level);
    2.81 		t->respond(t, STATUS_OS2_INVALID_LEVEL);