Re: [PATCH] loopdev: fix losetup failure with a lost device file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-10-18 19:59, Karel Zak wrote:
On Thu, Oct 12, 2023 at 02:55:24PM -0700, Junxiao Bi wrote:
+	sprintf(path, "/dev/loop%d", nr);
+	/* default loop device permission is "brw-rw----" */
+	umask(0003);
+	ret = mknod(path, S_IFBLK|0660, makedev(major, minor));
+	if (ret)
+		return -1;

frankly, it will be challenging to convince me that using mknode in a
tool like losetup is a good idea. After all these decades, it's still
not a common practice (although I have see many attempts).  Nodes are
typically created by udevd by default, following udev rules.

IMHO, it's better to report the problem (perhaps with a helpful hint)
as error message and assume that the administrator will address it.

Perhaps a separate exit status could also be returned? By the way, when does actually losetup(8) return 2, as described in the man page? I'm having troubles finding the exact place in the source code where that happens.



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux