Where to save stuff (in snap-agnostic way)

XiaoGuo Liu xiaoguo.liu at canonical.com
Wed Feb 8 01:27:54 UTC 2017


Hi Jamie,

Thanks for your explanation. You are right. The directory name takes the
very first execution of the command. After that, when accessing the /tmp
directory, it uses the directory created earlier if it is running from
another command.

I have updated my example code at
https://github.com/liu-xiao-guo/helloworld-fifo

When I firstly run "hello.fifo", the directory name takes something
"like snap.1000_snap.hello.fifo_5BpMiB". When trying to write to it using
"hello.fifo1", the same directory is used.

When I firstly run "hello.fifo1", the directory name takes something
"snap.1000_snap.hello.fifo1_6MJX5m". When trying to write to it using
"hello.fifo", the same directory is used.

Thanks & best regards,
XiaoGuo


On Wed, Feb 8, 2017 at 12:21 AM, Jamie Strandboge <jamie at canonical.com>
wrote:

> On Tue, 2017-02-07 at 12:04 +0800, XiaoGuo Liu wrote:
> > Hi Jamie,
> >
> > For my sample app at https://github.com/liu-xiao-guo/helloworld-fifo, I
> > tried to use the /tmp file to create a file, and  finally I get a file on
> > my Desktop like:
> >
> > root at liuxg:/tmp/snap.1000_snap.hello.fifo_TovLTW/tmp# ls
> > anothefile
> >
> > It seems to me that the path is still related to the command name "fifo".
> > Does this conflict with your saying?
>
> It does not. That directory is what is bind mounted into mount namespace
> and
> that is remembered for subsequent invocations of that command or other
> commands
> from the same snap. Try it: create a snap with two commands, have one
> create a
> file in /tmp and another to read the same file in /tmp-- it will work and
> the
> temporary directory in the system's /tmp will be
> /tmp/snap.0_snap.$SNAP_NAME.<first invoked command>_... will have the
> file you
> created in it.
>
> --
> Jamie Strandboge             | http://www.canonical.com
>
>
> --
> Snapcraft mailing list
> Snapcraft at lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
>


-- 
XiaoGuo, Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/snapcraft/attachments/20170208/5fb76291/attachment.html>


More information about the Snapcraft mailing list