Is there a Linux system call to create a “view” of a range of a file?Create a virtual file that is...

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Eww, those bytes are gross

Why did Luke use his left hand to shoot?

Does every functor from Set to Set preserve products?

In mixed effect models, how account for grouped random effects?

Does Skippy chunky peanut butter contain trans fat?

Can you tell from a blurry photo if focus was too close or too far?

Increment each digit in a number to form a new number

In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?

Play Zip, Zap, Zop

Graph with overlapping labels

Why did Democrats in the Senate oppose the Born-Alive Abortion Survivors Protection Act (2019 S.130)?

Alien invasion to probe us, why?

Finding a logistic regression model which can achieve zero error on a training set training data for a binary classification problem with two features

Can my spouse sponsor me for a UK visa if I am unemployed?

Can we harness gravitational potential energy?

Slow While Loop, Query Improvment Assistance

Potential client has a problematic employee I can't work with

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Citing paywalled articles accessed via illegal web sharing

How can I get my players to come to the game session after agreeing to a date?

Should I reinstall Linux when changing the laptop's CPU?

If I delete my router's history can my ISP still provide it to my parents?



Is there a Linux system call to create a “view” of a range of a file?


Create a virtual file that is actually a commandWhat options are there for tuning Linux file system caching?File name in file systemAutomating textual input from a bash script without using EOFHow to create low-overhead file systemMerge chunks from multiple fileswrite() system call ignores file permissionsDo system calls call themselves?How to create file set in Linux?Linux File system auto extendDo typical system call interfaces allow reducing the size of a file (without replacing it with a different inode)?













3















Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify it or generate a new file descriptor where file offsets are relative to the beginning of the range and end at the end of the range.



The use-case would be to limit a non-cooperating subprocess to accessing only a particular portion of an input file.










share|improve this question









New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • See also Create a virtual file that is actually a command

    – Gilles
    59 mins ago


















3















Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify it or generate a new file descriptor where file offsets are relative to the beginning of the range and end at the end of the range.



The use-case would be to limit a non-cooperating subprocess to accessing only a particular portion of an input file.










share|improve this question









New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • See also Create a virtual file that is actually a command

    – Gilles
    59 mins ago
















3












3








3








Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify it or generate a new file descriptor where file offsets are relative to the beginning of the range and end at the end of the range.



The use-case would be to limit a non-cooperating subprocess to accessing only a particular portion of an input file.










share|improve this question









New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify it or generate a new file descriptor where file offsets are relative to the beginning of the range and end at the end of the range.



The use-case would be to limit a non-cooperating subprocess to accessing only a particular portion of an input file.







linux files filesystems






share|improve this question









New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 59 mins ago









Gilles

539k12810911606




539k12810911606






New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









llasramllasram

1163




1163




New contributor




llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






llasram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • See also Create a virtual file that is actually a command

    – Gilles
    59 mins ago





















  • See also Create a virtual file that is actually a command

    – Gilles
    59 mins ago



















See also Create a virtual file that is actually a command

– Gilles
59 mins ago







See also Create a virtual file that is actually a command

– Gilles
59 mins ago












1 Answer
1






active

oldest

votes


















4














One way of doing this is to use a loop device. This approach does have two requirements which may make it less useful: you need to be root to set it up, and the non-cooperating subprocess must be able to write to a block device. Oh, and it doesn’t deal with conflicting changes.



To set the loop device up, run



losetup -o 1024 --sizelimit 2048 --show -f yourfile


replacing 1024, 2048 and yourfile with appropriate values — -o specifies the start offset, --sizelimit the size (counting from the offset). Note that sizelimit has to be a multiple of 512.



This will output the name of the loop device which has been set up; adjust the permissions as necessary, and give it to your non-cooperating sub-process. When you no longer need the device, delete it with



losetup -d /dev/loopN


replacing N as appropriate.






share|improve this answer


























  • Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

    – ilkkachu
    39 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






llasram is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503382%2fis-there-a-linux-system-call-to-create-a-view-of-a-range-of-a-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














One way of doing this is to use a loop device. This approach does have two requirements which may make it less useful: you need to be root to set it up, and the non-cooperating subprocess must be able to write to a block device. Oh, and it doesn’t deal with conflicting changes.



To set the loop device up, run



losetup -o 1024 --sizelimit 2048 --show -f yourfile


replacing 1024, 2048 and yourfile with appropriate values — -o specifies the start offset, --sizelimit the size (counting from the offset). Note that sizelimit has to be a multiple of 512.



This will output the name of the loop device which has been set up; adjust the permissions as necessary, and give it to your non-cooperating sub-process. When you no longer need the device, delete it with



losetup -d /dev/loopN


replacing N as appropriate.






share|improve this answer


























  • Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

    – ilkkachu
    39 mins ago
















4














One way of doing this is to use a loop device. This approach does have two requirements which may make it less useful: you need to be root to set it up, and the non-cooperating subprocess must be able to write to a block device. Oh, and it doesn’t deal with conflicting changes.



To set the loop device up, run



losetup -o 1024 --sizelimit 2048 --show -f yourfile


replacing 1024, 2048 and yourfile with appropriate values — -o specifies the start offset, --sizelimit the size (counting from the offset). Note that sizelimit has to be a multiple of 512.



This will output the name of the loop device which has been set up; adjust the permissions as necessary, and give it to your non-cooperating sub-process. When you no longer need the device, delete it with



losetup -d /dev/loopN


replacing N as appropriate.






share|improve this answer


























  • Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

    – ilkkachu
    39 mins ago














4












4








4







One way of doing this is to use a loop device. This approach does have two requirements which may make it less useful: you need to be root to set it up, and the non-cooperating subprocess must be able to write to a block device. Oh, and it doesn’t deal with conflicting changes.



To set the loop device up, run



losetup -o 1024 --sizelimit 2048 --show -f yourfile


replacing 1024, 2048 and yourfile with appropriate values — -o specifies the start offset, --sizelimit the size (counting from the offset). Note that sizelimit has to be a multiple of 512.



This will output the name of the loop device which has been set up; adjust the permissions as necessary, and give it to your non-cooperating sub-process. When you no longer need the device, delete it with



losetup -d /dev/loopN


replacing N as appropriate.






share|improve this answer















One way of doing this is to use a loop device. This approach does have two requirements which may make it less useful: you need to be root to set it up, and the non-cooperating subprocess must be able to write to a block device. Oh, and it doesn’t deal with conflicting changes.



To set the loop device up, run



losetup -o 1024 --sizelimit 2048 --show -f yourfile


replacing 1024, 2048 and yourfile with appropriate values — -o specifies the start offset, --sizelimit the size (counting from the offset). Note that sizelimit has to be a multiple of 512.



This will output the name of the loop device which has been set up; adjust the permissions as necessary, and give it to your non-cooperating sub-process. When you no longer need the device, delete it with



losetup -d /dev/loopN


replacing N as appropriate.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 hours ago









Stéphane Chazelas

307k57581938




307k57581938










answered 2 hours ago









Stephen KittStephen Kitt

173k24396471




173k24396471













  • Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

    – ilkkachu
    39 mins ago



















  • Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

    – ilkkachu
    39 mins ago

















Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

– ilkkachu
39 mins ago





Hmm, what do you mean with conflicting changes? Do you mean writes that come through the loop device not being in sync with direct writes to the backing file?

– ilkkachu
39 mins ago










llasram is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















llasram is a new contributor. Be nice, and check out our Code of Conduct.













llasram is a new contributor. Be nice, and check out our Code of Conduct.












llasram is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503382%2fis-there-a-linux-system-call-to-create-a-view-of-a-range-of-a-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Benedict Cumberbatch Contingut Inicis Debut professional Premis Filmografia bàsica Premis i...

Monticle de plataforma Contingut Est de Nord Amèrica Interpretacions Altres cultures Vegeu...

Escacs Janus Enllaços externs Menú de navegacióEscacs JanusJanusschachBrainKing.comChessV