[vminitd]: api for freeze/thaw filesystem operations#685
[vminitd]: api for freeze/thaw filesystem operations#685saehejkang wants to merge 2 commits intoapple:mainfrom
Conversation
|
@dcantah wdyt? |
|
Looks good! |
| #if os(Linux) | ||
| static let FIFREEZE: UInt = 0xC004_5877 | ||
| let rc: CInt = ioctl(fd, FIFREEZE, 0) | ||
| if rc != 0 { | ||
| throw RPCError(code: .internalError, message: "freeze failed") | ||
| } | ||
| #else | ||
| fatalError("freeze not supported on platform") | ||
| #endif | ||
| } | ||
|
|
||
| private func thawFilesystem(fd: Int32) throws { | ||
| #if os(Linux) | ||
| static let FITHAW: UInt = 0xC004_5878 | ||
| let rc: CInt = ioctl(fd, FITHAW, 0) | ||
| if rc != 0 { | ||
| throw RPCError(code: .internalError, message: "thaw failed") | ||
| } | ||
| #else | ||
| fatalError("thaw not supported on platform") | ||
| #endif |
There was a problem hiding this comment.
I'd leave off the ifdefs, I think we've somewhat accepted that we just care about linux here. I need to go and do a sweep everywhere.
There was a problem hiding this comment.
The rpc itself is already linux specific.
| log.debug( | ||
| "filesystemOperation: freezing filesystem", | ||
| metadata: [ | ||
| "path": "\(request.path)" | ||
| ]) |
There was a problem hiding this comment.
I'd get rid of these logs, it doesn't give us any extra info than the one at the top of the method.
| throw RPCError(code: .notFound, message: "failed to stat path") | ||
| } | ||
|
|
||
| if (finfo.st_mode & S_IFMT) == S_IFLNK { | ||
| throw RPCError(code: .internalError, message: "path cannot be a symlink") | ||
| } | ||
|
|
||
| fd = open(request.path, O_RDONLY) | ||
| if fd < 0 { | ||
| throw RPCError(code: .internalError, message: "failed to open path") |
There was a problem hiding this comment.
It'd be good in any syscall error return paths to include the errno, it'll be very hard to debug otherwise.
|
|
||
| private func thawFilesystem(fd: Int32) throws { | ||
| #if os(Linux) | ||
| static let FITHAW: UInt = 0xC004_5878 |
There was a problem hiding this comment.
Suggestion: static let inside Swift function is not allowed. Linux build will fail.
|
|
||
| private func freezeFilesystem(fd: Int32) throws { | ||
| #if os(Linux) | ||
| static let FIFREEZE: UInt = 0xC004_5877 |
There was a problem hiding this comment.
same as the other comment.
| throw RPCError(code: .internalError, message: "path cannot be a symlink") | ||
| } | ||
|
|
||
| fd = open(request.path, O_RDONLY) |
Addition of
vminitdAPI for freeze/thaw filesystem operationsCloses #660