-
Notifications
You must be signed in to change notification settings - Fork 305
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
checkout/commit: Use glnx_regfile_copy_bytes() if possible #817
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule libglnx
updated
from 602fdd to 3a4d0f
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 |
---|---|---|
|
@@ -459,29 +459,19 @@ add_size_index_to_metadata (OstreeRepo *self, | |
} | ||
|
||
static gboolean | ||
fallocate_stream (GFileDescriptorBased *stream, | ||
goffset size, | ||
GCancellable *cancellable, | ||
GError **error) | ||
ot_fallocate (int fd, goffset size, GError **error) | ||
{ | ||
gboolean ret = FALSE; | ||
int fd = g_file_descriptor_based_get_fd (stream); | ||
if (size == 0) | ||
return TRUE; | ||
|
||
if (size > 0) | ||
int r = posix_fallocate (fd, 0, size); | ||
if (r != 0) | ||
{ | ||
int r = posix_fallocate (fd, 0, size); | ||
if (r != 0) | ||
{ | ||
/* posix_fallocate is a weird deviation from errno standards */ | ||
errno = r; | ||
glnx_set_error_from_errno (error); | ||
goto out; | ||
} | ||
/* posix_fallocate is a weird deviation from errno standards */ | ||
errno = r; | ||
return glnx_throw_errno_prefix (error, "fallocate"); | ||
} | ||
|
||
ret = TRUE; | ||
out: | ||
return ret; | ||
return TRUE; | ||
} | ||
|
||
gboolean | ||
|
@@ -511,11 +501,10 @@ _ostree_repo_open_content_bare (OstreeRepo *self, | |
&fd, &temp_filename, error)) | ||
goto out; | ||
|
||
ret_stream = g_unix_output_stream_new (fd, TRUE); | ||
|
||
if (!fallocate_stream ((GFileDescriptorBased*)ret_stream, content_len, | ||
cancellable, error)) | ||
if (!ot_fallocate (fd, content_len, error)) | ||
goto out; | ||
|
||
ret_stream = g_unix_output_stream_new (fd, TRUE); | ||
} | ||
|
||
ret = TRUE; | ||
|
@@ -570,28 +559,34 @@ create_regular_tmpfile_linkable_with_content (OstreeRepo *self, | |
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
g_autoptr(GOutputStream) temp_out = NULL; | ||
glnx_fd_close int temp_fd = -1; | ||
g_autofree char *temp_filename = NULL; | ||
|
||
if (!glnx_open_tmpfile_linkable_at (self->tmp_dir_fd, ".", O_WRONLY|O_CLOEXEC, | ||
&temp_fd, &temp_filename, | ||
error)) | ||
return FALSE; | ||
temp_out = g_unix_output_stream_new (temp_fd, FALSE); | ||
|
||
if (!fallocate_stream ((GFileDescriptorBased*)temp_out, length, | ||
cancellable, error)) | ||
if (!ot_fallocate (temp_fd, length, error)) | ||
return FALSE; | ||
|
||
if (g_output_stream_splice (temp_out, input, 0, | ||
cancellable, error) < 0) | ||
return FALSE; | ||
if (fchmod (temp_fd, 0644) < 0) | ||
if (G_IS_FILE_DESCRIPTOR_BASED (input)) | ||
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. Here too. Seems like they're always fd-based, no? I'm not very familiar with GIO. |
||
{ | ||
glnx_set_error_from_errno (error); | ||
return FALSE; | ||
int infd = g_file_descriptor_based_get_fd ((GFileDescriptorBased*) input); | ||
if (glnx_regfile_copy_bytes (infd, temp_fd, (off_t)length, TRUE) < 0) | ||
return glnx_throw_errno_prefix (error, "regfile copy"); | ||
} | ||
else | ||
{ | ||
g_autoptr(GOutputStream) temp_out = g_unix_output_stream_new (temp_fd, FALSE); | ||
if (g_output_stream_splice (temp_out, input, 0, | ||
cancellable, error) < 0) | ||
return FALSE; | ||
} | ||
|
||
if (fchmod (temp_fd, 0644) < 0) | ||
return glnx_throw_errno_prefix (error, "fchmod"); | ||
|
||
*out_fd = temp_fd; temp_fd = -1; | ||
*out_path = g_steal_pointer (&temp_filename); | ||
return TRUE; | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will this condition ever fail?
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.
We expose as public API:
So we have to support it. In practice using the command line tools, we will go through this code path when pulling from an
archive
repo to abare
one, since the content objects are zlib-compressed.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.
Oh right, that makes sense.