From: Matthew Dillon Date: Thu, 22 Mar 2018 01:11:10 +0000 (-0700) Subject: kernel - Fix tapN creation >= 32 units, fix pty issues >= 32 ptys X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/095422fab17a80173d19945ec66d07cdd9fa1b44 kernel - Fix tapN creation >= 32 units, fix pty issues >= 32 ptys * Fix ifconfig tapN create for N >= 32. * devfs_clone_bitmap_chk(), which only if_tap uses, was returning the wrong default value for unit numbers beyond the current dynamic size of the bitmap. * Both devfs_clone_bitmap_chk() and devfs_clone_bitmap_put() were improperly using (1 << unit) instead of (1L << unit) when masking the 64-bit (long) bitmap elements, resulting in chaos for units >= 32. * This also should fix pty issues >= 32 ptys. Reported-by: Aaron Li --- diff --git a/sys/vfs/devfs/devfs_helper.c b/sys/vfs/devfs/devfs_helper.c index a3807588b4..c906e22429 100644 --- a/sys/vfs/devfs/devfs_helper.c +++ b/sys/vfs/devfs/devfs_helper.c @@ -104,7 +104,13 @@ devfs_clone_bitmap_fff(struct devfs_bitmap *bitmap) return -1; } - +/* + * Caller wants to know if the specified unit has been allocated + * or not. Return 0, indicating that it has not been allocated. + * + * (the bitmap implements 0=allocated, 1=not-allocated but the + * return value is inverted). + */ int devfs_clone_bitmap_chk(struct devfs_bitmap *bitmap, int unit) { @@ -114,9 +120,9 @@ devfs_clone_bitmap_chk(struct devfs_bitmap *bitmap, int unit) unit -= chunk * (sizeof(u_long) * 8); if (chunk >= bitmap->chunks) - return 1; + return 0; /* device does not exist */ - return !((bitmap->bitmap[chunk]) & (1 << unit)); + return !((bitmap->bitmap[chunk]) & (1L << unit)); } @@ -150,7 +156,7 @@ devfs_clone_bitmap_put(struct devfs_bitmap *bitmap, int unit) if (chunk >= bitmap->chunks) return; - bitmap->bitmap[chunk] |= (1 << unit); + bitmap->bitmap[chunk] |= (1L << unit); } /*