commit d4e438158258d53a0d22189b432537b22300dd2e from: Omar Polo date: Wed Dec 15 08:41:22 2021 UTC allow opening directories (for reading only) commit - 7abcb0db7fc2702872e6c25fa74c412d21d58893 commit + d4e438158258d53a0d22189b432537b22300dd2e blob - d96512f4d3f0b986bb0893f1f08bd72d923556bd blob + 8237f9706cffd481702b8272b3a7d4f2e6a9fab9 --- client.c +++ client.c @@ -1068,19 +1068,14 @@ topen(struct np_msg_header *hdr, const uint8_t *data, return; } - if (f->qid->type & QTDIR) { - /* - * XXX: real 9P2000 uses reads on directories to list the - * files, but 9P2000.L (and possibly .U too) uses - * Treaddir. It's my intention to support the 9p-style - * read-on-dir, just not yet. - */ - np_error(hdr->tag, "can't do I/O on directories yet"); + if (npmode_to_unix(mode, &f->iomode) == -1) { + np_error(hdr->tag, "invalid mode"); return; } - if (npmode_to_unix(mode, &f->iomode) == -1) { - np_error(hdr->tag, "invalid mode"); + if (f->qid->type & QTDIR && + (f->iomode & O_WRONLY || f->iomode & O_RDWR)) { + np_error(hdr->tag, "can't open directory for writing"); return; }