FreeBSD Bugzilla – Attachment 195669 Details for
Bug 230220
UFS: the freezing ioctl (i.e.UFSSUSPEND) causes panic or EBUSY
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
test-freeze-thaw.c
test-freeze-thaw.c (text/plain), 2.07 KB, created by
Dexuan Cui
on 2018-07-31 02:05:06 UTC
(
hide
)
Description:
test-freeze-thaw.c
Filename:
MIME Type:
Creator:
Dexuan Cui
Created:
2018-07-31 02:05:06 UTC
Size:
2.07 KB
patch
obsolete
>#include <string.h> >#include <stdio.h> >#include <sys/ioctl.h> >#include <sys/param.h> >#include <sys/ucred.h> >#include <sys/mount.h> >#include <sys/types.h> > >#include <unistd.h> >#include <stdlib.h> >#include <poll.h> >#include <stdint.h> >#include <syslog.h> >#include <errno.h> >#include <err.h> >#include <fcntl.h> >#include <ufs/ffs/fs.h> >#include <paths.h> >#include <sysexits.h> > >static int g_ufs_suspend_handle = -1; >static const char *dev = "/dev"; > >static int freeze(void) >{ > struct statfs *mntbuf, *statfsp; > int mntsize; > int error = 0; > int i; > > g_ufs_suspend_handle = open(_PATH_UFSSUSPEND, O_RDWR); > if (g_ufs_suspend_handle == -1) { > printf("unable to open %s", _PATH_UFSSUSPEND); > return (errno); > } > > mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); > if (mntsize == 0) { > printf("There is no mount information\n"); > return (EINVAL); > } > > for (i = mntsize - 1; i >= 0; --i) > { > statfsp = &mntbuf[i]; > > if (strncmp(statfsp->f_mntonname, dev, strlen(dev)) == 0) > continue; /* skip to freeze '/dev' */ > > if (statfsp->f_flags & MNT_RDONLY) > continue; /* skip to freeze RDONLY partition */ > > if (strncmp(statfsp->f_fstypename, "ufs", 3) != 0) > continue; /* so far, only UFS can be frozen */ > > printf("suspending fs: %s\n", statfsp->f_mntonname); > error = ioctl(g_ufs_suspend_handle, UFSSUSPEND, &statfsp->f_fsid); > if (error != 0) { > printf("error: %d\n", errno); > error = errno; > } else { > printf("Successfully suspend fs: %s\n", statfsp->f_mntonname); > } > } > > return (error); >} > >/** > * closing the opened handle will thaw the FS. > */ >static int thaw(void) >{ > int error = 0; > > if (g_ufs_suspend_handle != -1) { > error = close(g_ufs_suspend_handle); > if (!error) { > g_ufs_suspend_handle = -1; > printf("Successfully thaw the fs\n"); > } else { > error = errno; > printf("Fail to thaw the fs: " > "%d %s\n", errno, strerror(errno)); > } > } else { > printf("The fs has already been thawed\n\n"); > } > > return (error); >} > > >int main(int argc, char* argv[]) >{ > int error; > > error = freeze(); > printf("freeze: err=%d\n\n", error); > > error = thaw(); > printf("thaw: err=%d\n", error); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 230220
: 195669 |
195682
|
195685