From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 3256 invoked from network); 10 Feb 2021 23:42:04 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 10 Feb 2021 23:42:04 -0000 Received: from mail-yb1-f175.google.com ([209.85.219.175]) by 1ess; Wed Feb 10 18:33:28 -0500 2021 Received: by mail-yb1-f175.google.com with SMTP id r2so3779245ybk.11 for <9front@9front.org>; Wed, 10 Feb 2021 15:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:to:subject:date:mime-version :content-transfer-encoding; bh=6PkAFuRCwHojslaB7m9DZtqwndw2PscMULpS2ZWdwKY=; b=qyh36049m5UiUx98jxDbMLqSQPugS+5X6izOHYgCF+mI5bjVaj6OT89ugL+R6DKd27 1L4SntRhy6KitvllkEY7W84TDnb9+9TZDZaAx15hFt/KrfjHTwRBQj0rCFhaRVxy49ps 1FLxHohCW31QwWyvhBaCIbvz3fza16IkdyIbJwCd4TGDtqoVjEecAJVXWJJdK3+nrs2P iT0/mBTHpLFns9TJS7d/ySzLvQ0LtPjGNKKEq6HHkWL484rsRWR3x9AaVcjJqC1OhrJR xhmihSkFebjfudEENVV31HSb5taB2R1AFECtV9Kt69WJbOHxqkx+ngQqMVteSwPHk+ic KjxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:to:subject:date:mime-version :content-transfer-encoding; bh=6PkAFuRCwHojslaB7m9DZtqwndw2PscMULpS2ZWdwKY=; b=kjYd8oDo2AZU5TwyK6vinGY4ewWKzvWRQE58mkfX/QOXVAJuL5xoXyNschhStmOA8o yV2dxw9wPV87asS7izsyHC3Pg4D8Gamdw1o5kZTj6K5H14ZUuQghvtmQ3F3+qjdU8mJM i9h6AglVVdhiu7RRgniNqGLDMpmH1OCxlMJws1VqqMVUY1nrIIiOuIsgXkFti98hH1Wr Uj+V9DGE+ZP3TNpk4k5VG165yvLQvEQP7UOLhuBUQRKmux9dYSRFAMMHJJTKWGSMk9E6 o66AdSHnfweVtUGccWAQBfOJl/qM1jUTtVMgzSBqjI83x3T3cR1m9aStjhBBikeePgjH mMZA== X-Gm-Message-State: AOAM533QsNYdSMj73r1l9PdAlluDy3W6cWBZLCCnHrke91W6XrF6ZnAg RtTGJq5pike5G+aK1slEro1XLu70Ll8= X-Google-Smtp-Source: ABdhPJwOD2RVB7pI4XIyoHpB0aFyOTE7mZFDj1mF8o+EQWeDLr24pSc6xTYqKaEQ9biJj9RnrIntbw== X-Received: by 2002:a05:6830:131a:: with SMTP id p26mr3705442otq.134.1612998372398; Wed, 10 Feb 2021 15:06:12 -0800 (PST) Return-Path: Received: from dell9term.covert9net (67-198-106-217.dyn.grandenetworks.net. [67.198.106.217]) by smtp.gmail.com with ESMTPSA id k131sm505277oib.49.2021.02.10.15.06.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Feb 2021 15:06:11 -0800 (PST) From: covertusername967@gmail.com X-Google-Original-From: glenda@gmail.com Message-ID: <373D8A66AC0E86E835D394546F63BB20@gmail.com> To: covertusername967@gmail.com, 9front@9front.org Date: Wed, 10 Feb 2021 17:06:11 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: core cloud JSON descriptor CMS framework Subject: [9front] [patch] devshr: allow posting plain directories Reply-To: 9front@9front.org Precedence: bulk Per popular* request, I am posting this to the mailing list. This is something I put together for personal use, so it is not quite polished. See the BUGS section in the patch for the manpage. Currently, devshr only allows you to post 9p channels to it. This is fine and all, but it's handy to be able to post a directory to it. This allows us to get around exportfs with its pseudo mountpoint limit and access the directory tree directly. *sirjofri's diff -r ab517fbe257d sys/man/3/shr --- a/sys/man/3/shr Tue Feb 09 23:11:08 2021 -0500 +++ b/sys/man/3/shr Wed Feb 10 16:11:50 2021 -0600 @@ -16,7 +16,7 @@ device provides global mountpoints in the form of share directories where .IR 9P -services can be mounted. +services can be mounted, as well as arbitrary directories. Effectively, it is a global mountpoint registry that is separate from private namespaces. @@ -42,7 +42,9 @@ .IR atof (2)) giving the file descriptor number of an open .I 9P -service. Any process +service. To post a directory, write the pathname. Relative pathnames are only accepted if they have a leading +.B ./ . +Any process with the proper permission may then access .B #σ/myshare on the mount tree. @@ -70,8 +72,17 @@ mkdir '#σc'/myshare echo 3 > '#σc'/myshare/myserv <>[3]/srv/myserv .EE +To share a directory from your private namespace to the rest of the system +.EX +mkdir '#σc'/myshare +echo /n/privatedir > '#σc'/myshare/mydir +.EE .SH SOURCE .B /sys/src/9/port/devshr.c .SH HISTORY .I Shr first appeared in 9front (July, 2011). +.SH BUGS +Mountpoints that exist below posted directories are not visible in the share. +.PP +If a union directory is posted, only the topmost directory in the union is visible. The union must be recreated manually if it is needed, and this is somewhat cumbersome. diff -r ab517fbe257d sys/src/9/port/devshr.c --- a/sys/src/9/port/devshr.c Tue Feb 09 23:11:08 2021 -0500 +++ b/sys/src/9/port/devshr.c Wed Feb 10 16:11:50 2021 -0600 @@ -744,23 +744,33 @@ } memmove(buf, va, n); buf[n] = 0; - - fd = strtol(buf, &p, 10); - if(p == buf || (*p != 0 && *p != '\n')) - error(Ebadarg); - if(*p == '\n' && *(p+1) != 0) - aname = p + 1; - else - aname = nil; - - bc = fdtochan(fd, ORDWR, 0, 1); - if(waserror()) { + + if(buf[0] == '/' || buf[0] == '.' || buf[0] == '#'){ + if(buf[n-1] == '\n') + buf[n-1] = 0; + c0 = namec(buf, Abind, 0, 0); + if(!(c0->qid.type & QTDIR)){ + cclose(c0); + error(Enotdir); + } + } else { + fd = strtol(buf, &p, 10); + if(p == buf || (*p != 0 && *p != '\n')) + error(Ebadarg); + if(*p == '\n' && *(p+1) != 0) + aname = p + 1; + else + aname = nil; + + bc = fdtochan(fd, ORDWR, 0, 1); + if(waserror()){ + cclose(bc); + nexterror(); + } + c0 = mntattach(bc, nil, aname, 0); + poperror(); cclose(bc); - nexterror(); } - c0 = mntattach(bc, nil, aname, 0); - poperror(); - cclose(bc); poperror(); free(buf);