[PATCH:shmfd 2/2] Use /var/tmp instead of /run/shm on non-linux OS'es
Thomas Klausner
wiz at NetBSD.org
Fri Nov 8 06:49:27 PST 2013
On Fri, Nov 08, 2013 at 09:42:57AM -0500, Jasper St. Pierre wrote:
> We want to make sure we don't write files to disk. /tmp on some systems is
> backed by a disk, not tmpfs.
If you want real temporary files that don't survive a reboot, /tmp is
a better bet than /var/tmp.
See e.g.
http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#VARTMPTEMPORARYFILESPRESERVEDBETWEE
which says:
"The /var/tmp directory is made available for programs that require
temporary files or directories that are preserved between system
reboots. Therefore, data stored in /var/tmp is more persistent than
data in /tmp.
Files and directories located in /var/tmp must not be deleted when the
system is booted. Although data stored in /var/tmp is typically
deleted in a site-specific manner, it is recommended that deletions
occur at a less frequent interval than /tmp."
On NetBSD for example, /var/tmp is where the vi recovery files live.
Thomas
> On Fri, Nov 8, 2013 at 2:53 AM, Mark Kettenis <mark.kettenis at xs4all.nl>wrote:
>
> > > From: Alan Coopersmith <alan.coopersmith at oracle.com>
> > > Date: Thu, 7 Nov 2013 20:55:44 -0800
> > >
> > > Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> > > ---
> > > Makefile | 9 +++++----
> > > shmfd.c | 4 ++++
> > > 2 files changed, 9 insertions(+), 4 deletions(-)
> >
> > Ah, is this the example code I have been looking for the last couple
> > of days?
> >
> > Anyway, wouldn't it be better to use /tmp instead of adding this
> > (admittedly small) #ifdef spaghetti?
> >
> > > diff --git a/Makefile b/Makefile
> > > index e77f938..672979e 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -1,7 +1,8 @@
> > > -CFLAGS=-Wall -O0 -g $(shell pkg-config --cflags xcb-shm xcb-aux
> > xcb-dri3 xcb-present xshmfence)
> > > -LIBS=$(shell pkg-config --libs xcb-shm xcb-aux xcb-dri3 xcb-present
> > xshmfence)
> > > +CFLAGS=-Wall -O0 -g $(shell pkg-config --cflags xcb-shm xcb-aux
> > xcb-dri3 xcb-present) -m64
> > > +LIBS=$(LDFLAGS) $(shell pkg-config --libs xcb-shm xcb-aux xcb-dri3
> > xcb-present)
> > >
> > > -all: shmfd dri3 futex xfence present pipefence shmtest
> > > +#all: shmfd dri3 futex xfence present pipefence shmtest
> > > +all: shmfd present
> > >
> > > SHMFD_OBJS=shmfd.o
> > >
> > > @@ -42,4 +43,4 @@ clean:
> > > rm -f shmfd $(SHMFD_OBJS)
> > > rm -f dri3 $(DRI3_OBJS)
> > > rm -f futex $(FUTEX_OBJS)
> > > - rm -f present $(PRESENT_OBJS)
> > > \ No newline at end of file
> > > + rm -f present $(PRESENT_OBJS)
> > > diff --git a/shmfd.c b/shmfd.c
> > > index 4dee9de..cdd3889 100644
> > > --- a/shmfd.c
> > > +++ b/shmfd.c
> > > @@ -32,7 +32,11 @@ int
> > > make_shm(int size, void **addrp)
> > > {
> > > void *addr;
> > > +#ifdef linux
> > > char template[] = "/run/shm/shmfd-XXXXXX";
> > > +#else
> > > + char template[] = "/var/tmp/shmfd-XXXXXX";
> > > +#endif
> > > int fd = mkstemp(template);
> > >
> > > if (fd < 0)
> > > --
> > > 1.7.9.2
> > >
> > > _______________________________________________
> > > xorg-devel at lists.x.org: X.Org development
> > > Archives: http://lists.x.org/archives/xorg-devel
> > > Info: http://lists.x.org/mailman/listinfo/xorg-devel
> > >
> > _______________________________________________
> > xorg-devel at lists.x.org: X.Org development
> > Archives: http://lists.x.org/archives/xorg-devel
> > Info: http://lists.x.org/mailman/listinfo/xorg-devel
> >
>
>
>
> --
> Jasper
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list