Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jun 2016 08:15:09 +0000
From:      Hongjiang Zhang <honzhan@microsoft.com>
To:        "freebsd-fs@freebsd.org" <freebsd-fs@freebsd.org>
Subject:   ufs freeze does not work
Message-ID:  <CO2PR03MB2215FAA1AB86A669039B9540B5210@CO2PR03MB2215.namprd03.prod.outlook.com>

next in thread | raw e-mail | index | archive | help
Hi all,

I wrote a test to freeze ufs, but it does not work even if the ioctl return=
s 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 =3D open(_PATH_UFSSUSPEND, O_RDWR);
        if (fso =3D=3D -1)
                err(1, "unable to open %s", _PATH_UFSSUSPEND);
        /*
         * First check the mounted filesystems.
         */
        mntsize =3D getmntinfo(&mntbuf, MNT_NOWAIT);
        if (mntsize =3D=3D 0)
                return;

        printf("mnt size: %d\n", mntsize);
        for(i =3D mntsize - 1; i >=3D 0; --i)
        {
                statfsp =3D &mntbuf[i];

                if (strcmp("/", statfsp->f_mntonname) =3D=3D 0 ||
                        strcmp("ufs", statfsp->f_fstypename) =3D=3D 0)
                {
                        printf("begin to suspend on '%s' from '%s'\n",
                                statfsp->f_mntonname, statfsp->f_mntfromnam=
e);

                        error =3D ioctl(fso, UFSSUSPEND, &statfsp->f_fsid);
                        if (error !=3D 0) {
                                //err(1, "UFSSUSPEND");
                                printf("error: %d\n",errno);
                       } else {
                                printf("Successfully suspend filesystem\n")=
;
                        }
                        break;
                }
        }
        close(fso);
}

Thanks
Hongjiang Zhang



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CO2PR03MB2215FAA1AB86A669039B9540B5210>