Skip to content

Commit

Permalink
stress2: Do not make assumptions about the value of UFS_LINK_MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
phoatfreebsd committed Nov 25, 2023
1 parent f72b4f7 commit 49a83b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/test/stress2/misc/nlink3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ main (void) {
err(1, "creat(%s)", file);
close(fd);
mx = UFS_LINK_MAX - 1; /* UFS_LINK_MAX = 32767 */
mx = UFS_LINK_MAX - 1;
for (i = 0; i < mx; i++) {
snprintf(file, sizeof(file), "%d", i);
if (link("f", file) == -1)
Expand Down
2 changes: 1 addition & 1 deletion tools/test/stress2/misc/nlink4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ main (void) {
err(1, "creat(%s)", file);
close(fd);
mx = UFS_LINK_MAX - 1; /* UFS_LINK_MAX = 32767 */
mx = UFS_LINK_MAX - 1;
for (i = 0; i < mx; i++) {
snprintf(file, sizeof(file), "%d", i);
if (link("f", file) == -1)
Expand Down
7 changes: 5 additions & 2 deletions tools/test/stress2/misc/nlink5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

. ../default.cfg

UFS_LINK_MAX=`grep UFS_LINK_MAX /usr/include/ufs/ufs/dinode.h 2>/dev/null`
[ -z "$UFS_LINK_MAX" ] && exit 0
UFS_LINK_MAX=`echo $UFS_LINK_MAX | awk '{print $NF}'`
cat > /tmp/nlink5.c <<EOF
#include <sys/stat.h>
#include <ufs/ufs/dinode.h>
Expand All @@ -46,7 +49,7 @@ main (void) {
int i, mx;
char dir[100];
mx = UFS_LINK_MAX - 2; /* UFS_LINK_MAX = 32767 */
mx = UFS_LINK_MAX - 2;
for (i = 0; i < mx; i++) {
snprintf(dir, sizeof(dir), "%d", i);
if (mkdir(dir, 0700) == -1)
Expand Down Expand Up @@ -111,7 +114,7 @@ set +e
cd $mntpoint
/tmp/nlink5; s=$?
n=`find . -type d -maxdepth 1 | wc -l`
[ $n -ne 32766 ] && s=2
[ $n -ne $((UFS_LINK_MAX - 1)) ] && s=2
cd $here

umount $mntpoint
Expand Down

0 comments on commit 49a83b9

Please sign in to comment.