-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: reimplement the depmod extension rebuilder
Drop loop device/mounts completely, use userspace utilities to extract and lay over module trees in the tmpfs. Discover kernel version automatically instead of hardcoding it to be current one (required for Image Service). Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit c5bd0ac)
- Loading branch information
Showing
5 changed files
with
125 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package extensions | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
) | ||
|
||
// discarder is used to implement ReadAt from a Reader | ||
// by reading, and discarding, data until the offset | ||
// is reached. It can only go forward. It is designed | ||
// for pipe-like files. | ||
type discarder struct { | ||
r io.Reader | ||
pos int64 | ||
} | ||
|
||
// ReadAt implements ReadAt for a discarder. | ||
// It is an error for the offset to be negative. | ||
func (r *discarder) ReadAt(p []byte, off int64) (int, error) { | ||
if off-r.pos < 0 { | ||
return 0, fmt.Errorf("negative seek on discarder not allowed") | ||
} | ||
|
||
if off != r.pos { | ||
i, err := io.Copy(io.Discard, io.LimitReader(r.r, off-r.pos)) | ||
if err != nil || i != off-r.pos { | ||
return 0, err | ||
} | ||
|
||
r.pos += i | ||
} | ||
|
||
n, err := io.ReadFull(r.r, p) | ||
if err != nil { | ||
return n, err | ||
} | ||
|
||
r.pos += int64(n) | ||
|
||
return n, err | ||
} | ||
|
||
var _ io.ReaderAt = &discarder{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters