ufs freeze does not work
Hongjiang Zhang
honzhan at microsoft.com
Mon Jun 27 08:15:18 UTC 2016
Hi all,
I wrote a test to freeze ufs, but it does not work even if the ioctl returns successful. What is the problem?
#define _PATH_UFSSUSPEND "/dev/ufssuspend"
static void freeze_allmountpoints()
{
struct statfs *mntbuf, *statfsp;
int mntsize;
int fso;
int error;
int i;
fso = open(_PATH_UFSSUSPEND, O_RDWR);
if (fso == -1)
err(1, "unable to open %s", _PATH_UFSSUSPEND);
/*
* First check the mounted filesystems.
*/
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
if (mntsize == 0)
return;
printf("mnt size: %d\n", mntsize);
for(i = mntsize - 1; i >= 0; --i)
{
statfsp = &mntbuf[i];
if (strcmp("/", statfsp->f_mntonname) == 0 ||
strcmp("ufs", statfsp->f_fstypename) == 0)
{
printf("begin to suspend on '%s' from '%s'\n",
statfsp->f_mntonname, statfsp->f_mntfromname);
error = ioctl(fso, UFSSUSPEND, &statfsp->f_fsid);
if (error != 0) {
//err(1, "UFSSUSPEND");
printf("error: %d\n",errno);
} else {
printf("Successfully suspend filesystem\n");
}
break;
}
}
close(fso);
}
Thanks
Hongjiang Zhang
More information about the freebsd-fs
mailing list