- mp = find_mount_point(G.device_name, NULL);
- if (mp && strcmp(G.device_name, mp->mnt_fsname) == 0)
- bb_error_msg_and_die("%s is mounted on %s; "
- "refusing to make a filesystem",
- G.device_name, mp->mnt_dir);
-
- G.dev_fd = xopen(G.device_name, O_RDWR);
- if (fstat(G.dev_fd, &statbuf) < 0)
- bb_error_msg_and_die("cannot stat %s", G.device_name);
+ if (find_mount_point(G.device_name, 0))
+ bb_error_msg_and_die("can't format mounted filesystem");
+
+ xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
+ xfstat(dev_fd, &statbuf, G.device_name);