[CRIU] [PATCH 2/5] crtools: chdir to images dir after processing all command line options
Ruslan Kuprieiev
kupruser at gmail.com
Thu Nov 14 14:22:26 PST 2013
On 14.11.2013 22:09, Pavel Emelyanov wrote:
> On 11/14/2013 11:59 PM, Ruslan Kuprieiev wrote:
>> On 12.11.2013 23:20, Pavel Emelyanov wrote:
>>> On 11/13/2013 01:42 AM, Ruslan Kuprieiev wrote:
>>>
>>> That's not natural. I'd expect that we chdir() to workdir ;)
>>> This will be a) natural and b) save one service fd.
>> Oh, so we could open logfiles/pidfiles/stats as is, without openat?
> Yes, like this.
>
>> But with service/server it will require absolute paths for
>> pidfiles/logfiles, as we are going to use -D to point daemon where to
>> chdir or aren't we?
> I think that with -W option daemon may not require absolute paths for
> logs and pidfiles and put them into -W dir.
>
>> And maybe it would be better, to chdir to imgs dir, as we may use it in
>> the future to recurrently go through the directory and, for example,
>> restore set of processes, and write all logs into one file somewhere
>> outside.
> I think we'd better stop chdir()-ing to images dir. We should use image_open
> and sfd-s to access them.
Oh, I see. Thanks.
>>>> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
>>>> ---
>>>> crtools.c | 12 +++++++-----
>>>> 1 file changed, 7 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/crtools.c b/crtools.c
>>>> index 4a0017f..b9313b1 100644
>>>> --- a/crtools.c
>>>> +++ b/crtools.c
>>>> @@ -78,6 +78,7 @@ int main(int argc, char *argv[])
>>>> int ret = -1;
>>>> int opt, idx;
>>>> int log_level = 0;
>>>> + char *imgs_dir = ".";
>>>>
>>>> BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
>>>>
>>>> @@ -163,11 +164,7 @@ int main(int argc, char *argv[])
>>>> opts.restore_detach = true;
>>>> break;
>>>> case 'D':
>>>> - if (chdir(optarg)) {
>>>> - pr_perror("Can't change directory to %s",
>>>> - optarg);
>>>> - return -1;
>>>> - }
>>>> + imgs_dir = optarg;
>>>> break;
>>>> case 'W':
>>>> break;
>>>> @@ -283,6 +280,11 @@ int main(int argc, char *argv[])
>>>> }
>>>> }
>>>>
>>>> + if (chdir(imgs_dir)) {
>>>> + pr_perror("Can't change directory to %s", optarg);
>>>> + return -1;
>>>> + }
>>>> +
>>>> log_set_loglevel(log_level);
>>>>
>>>> if (log_init(opts.output))
>>>>
>> .
>>
>
More information about the CRIU
mailing list