Commit 68d654da authored by Dan Schatzberg's avatar Dan Schatzberg Committed by Greg Kurz
Browse files

9pfs: Fix divide by zero bug



Some filesystems may return 0s in statfs (trivially, a FUSE filesystem
can do so). QEMU should handle this gracefully and just behave the
same as if statfs failed.

Signed-off-by: default avatarDan Schatzberg <dschatzberg@fb.com>
Acked-by: default avatarChristian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
parent 2061735f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1834,9 +1834,11 @@ static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
     * and as well as less than (client msize - P9_IOHDRSZ))
     */
    if (!v9fs_co_statfs(pdu, path, &stbuf)) {
        if (stbuf.f_bsize) {
            iounit = stbuf.f_bsize;
            iounit *= (s->msize - P9_IOHDRSZ) / stbuf.f_bsize;
        }
    }
    if (!iounit) {
        iounit = s->msize - P9_IOHDRSZ;
    }