-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers/quota.makeBackingFsDev(): use mknod+rename #1280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||||
//go:build linux && !exclude_disk_quota && cgo | ||||||
// +build linux,!exclude_disk_quota,cgo | ||||||
|
||||||
// | ||||||
|
@@ -394,10 +395,13 @@ func makeBackingFsDev(home string) (string, error) { | |||||
} | ||||||
|
||||||
backingFsBlockDev := path.Join(home, "backingFsBlockDev") | ||||||
backingFsBlockDevTmp := backingFsBlockDev + ".tmp" | ||||||
// Re-create just in case someone copied the home directory over to a new device | ||||||
unix.Unlink(backingFsBlockDev) | ||||||
if err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { | ||||||
return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDev, err) | ||||||
if err := unix.Mknod(backingFsBlockDevTmp, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { | ||||||
return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDevTmp, err) | ||||||
} | ||||||
if err := unix.Rename(backingFsBlockDevTmp, backingFsBlockDev); err != nil { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename is allowed over an existing device? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per rename(2), yes. We'll get EEXIST back if we're using renameat2() and with a RENAME_NOREPLACE flag. |
||||||
return "", fmt.Errorf("Failed to rename %s to %s: %v", backingFsBlockDevTmp, backingFsBlockDev, err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
return backingFsBlockDev, nil | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.