public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* non-persistant storage?
@ 2019-12-12 12:28 Ulli Horlacher
  2019-12-12 21:27 ` Eliot Moss
  2019-12-16 10:22 ` Corinna Vinschen
  0 siblings, 2 replies; 9+ messages in thread
From: Ulli Horlacher @ 2019-12-12 12:28 UTC (permalink / raw)
  To: cygwin

I need to store some data (a few kB) non-persistant.
On a real UNIX I would use /var/run, because after a shutdown all its
content is lost.
But on cygwin /var/run is stored on disk.

I cannot use an environment variable, because different processes need to
read/write the data.

/proc is non-persistant (in respect to a reboot), but It is not a generic
storage place.

What can I use with cygwin instead?

Installing third party software is not an option, it must work with a
standard Windows (and cygwin).

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<20191212120041.GA7699@tik.uni-stuttgart.de>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-12 12:28 non-persistant storage? Ulli Horlacher
@ 2019-12-12 21:27 ` Eliot Moss
  2019-12-12 21:40   ` Ulli Horlacher
  2019-12-16 10:22 ` Corinna Vinschen
  1 sibling, 1 reply; 9+ messages in thread
From: Eliot Moss @ 2019-12-12 21:27 UTC (permalink / raw)
  To: cygwin

On 12/12/2019 7:00 AM, Ulli Horlacher wrote:
> I need to store some data (a few kB) non-persistant.
> On a real UNIX I would use /var/run, because after a shutdown all its
> content is lost.
> But on cygwin /var/run is stored on disk.
> 
> I cannot use an environment variable, because different processes need to
> read/write the data.
> 
> /proc is non-persistant (in respect to a reboot), but It is not a generic
> storage place.
> 
> What can I use with cygwin instead?
> 
> Installing third party software is not an option, it must work with a
> standard Windows (and cygwin).

I would think of temp directories, such as /tmp.  They can be cleaned out at will
on restart, no?

Regards - Eliot

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-12 21:27 ` Eliot Moss
@ 2019-12-12 21:40   ` Ulli Horlacher
  2019-12-12 21:59     ` Eliot Moss
  0 siblings, 1 reply; 9+ messages in thread
From: Ulli Horlacher @ 2019-12-12 21:40 UTC (permalink / raw)
  To: cygwin

On Thu 2019-12-12 (14:18), Eliot Moss wrote:

> > I need to store some data (a few kB) non-persistant.
> > On a real UNIX I would use /var/run, because after a shutdown all its
> > content is lost.
> > But on cygwin /var/run is stored on disk.
> > 
> I would think of temp directories, such as /tmp.  They can be cleaned out at will
> on restart, no?

The data MUST be lost on shutdown (or power failure), not on reboot!
Therefore it must be hold in memory, not on disk.

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<8905c7b6-b2e6-52bf-bcdd-66890db91e9e@cs.umass.edu>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-12 21:40   ` Ulli Horlacher
@ 2019-12-12 21:59     ` Eliot Moss
  2019-12-13  1:33       ` L A Walsh
  0 siblings, 1 reply; 9+ messages in thread
From: Eliot Moss @ 2019-12-12 21:59 UTC (permalink / raw)
  To: cygwin

Ah!  I think what you want is a tmpfs or ramfs.
Not sure if cygwin supports that ...

Cheers - Eliot

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-12 21:59     ` Eliot Moss
@ 2019-12-13  1:33       ` L A Walsh
  2019-12-13  6:28         ` Brian Inglis
  2019-12-13 10:06         ` Ulli Horlacher
  0 siblings, 2 replies; 9+ messages in thread
From: L A Walsh @ 2019-12-13  1:33 UTC (permalink / raw)
  To: cygwin

On 2019/12/12 13:40, Eliot Moss wrote:
> Ah!  I think what you want is a tmpfs or ramfs.
> Not sure if cygwin supports that ...
>   
----
    Easiest thing might be to use /dev/shm. I used it during
development to store intermediate data that was later to be
transfered via a fifo...

Basically check for existence of "/dev/shm" (exists on my cygwin).
if "tmp" didn't already exist, create it w/options similar to
/tmp (only owner can delete/edit):

mkdir -m 1777 /tmp/shm/tmp


**Warning, "writes" to /dev/shm/tmp (or /dev/mem) can fill up
your system's memory, so its only good for "small files"
(small being well under your system's free memory amount).


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-13  1:33       ` L A Walsh
@ 2019-12-13  6:28         ` Brian Inglis
  2019-12-13  9:34           ` L A Walsh
  2019-12-13 10:06         ` Ulli Horlacher
  1 sibling, 1 reply; 9+ messages in thread
From: Brian Inglis @ 2019-12-13  6:28 UTC (permalink / raw)
  To: cygwin

On 2019-12-12 18:06, L A Walsh wrote:
> On 2019/12/12 13:40, Eliot Moss wrote:
>> Ah!  I think what you want is a tmpfs or ramfs.
>> Not sure if cygwin supports that ...
>>   
> ----
>    Easiest thing might be to use /dev/shm. I used it during
> development to store intermediate data that was later to be
> transfered via a fifo...
> 
> Basically check for existence of "/dev/shm" (exists on my cygwin).
> if "tmp" didn't already exist, create it w/options similar to
> /tmp (only owner can delete/edit):
> 
> mkdir -m 1777 /tmp/shm/tmp
> 
> 
> **Warning, "writes" to /dev/shm/tmp (or /dev/mem) can fill up
> your system's memory, so its only good for "small files"
> (small being well under your system's free memory amount).

I've been using /run, with /var/run as a symlink to that, created in a permanent
postinstall script /etc/postinstall/zp_mk_run_var_links.dash (with some others),
for some time. It's currently using ~28KB.

Is it feasible to mount /run on say /dev/shm/run and create and use files there?

Or would it be more feasible to use say Cyg/WinFUSE to provide that function?

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-13  6:28         ` Brian Inglis
@ 2019-12-13  9:34           ` L A Walsh
  0 siblings, 0 replies; 9+ messages in thread
From: L A Walsh @ 2019-12-13  9:34 UTC (permalink / raw)
  To: cygwin

On 2019/12/12 22:26, Brian Inglis wrote:
>
>
> I've been using /run, with /var/run as a symlink to that, created in a permanent
> postinstall script /etc/postinstall/zp_mk_run_var_links.dash (with some others),
> for some time. It's currently using ~28KB.
>
> Is it feasible to mount /run on say /dev/shm/run and create and use files there?
>   
I don't see why you would need to change what you are doing unless your 
application
whines about the symlink.  I.e. VirtualBox didn't like me using a symlink
in /opt to /home/opt on linux, so I mounted it w/a line in fstab.

/home/opt /opt  none  rbind 0 0

> Or would it be more feasible to use say Cyg/WinFUSE to provide that function?
>   
I don't know the state of cyg's support in those areas, so if you were 
forced
to change, you'd get to do your own testing to see what worked, etc.

I went one further under 'run' and 'tmp' -- I left those as public 
directories
and put my UID or login name as my own directory under the common name.

yeah 28k is nothing.  I was using files measured in MBytes though the 
[server]
system has over 100GB mem.  The communication goes through unix-sockets, 
which
also goes through /dev/shm, but its cleanup is technically the 
responsibility
of the OS, so, if lucky -- it cleans it up, if not, no worse off than 
before.

I don't run many OS progs on my Win machine cuz Win tended to flake out 
in running
tasks and wouldn't say anything when it went wrong.

So now, I just have a cronjobs on my linux server that use ssh to login 
to run
jobs on windows...

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-13  1:33       ` L A Walsh
  2019-12-13  6:28         ` Brian Inglis
@ 2019-12-13 10:06         ` Ulli Horlacher
  1 sibling, 0 replies; 9+ messages in thread
From: Ulli Horlacher @ 2019-12-13 10:06 UTC (permalink / raw)
  To: cygwin

On Thu 2019-12-12 (17:06), L A Walsh wrote:

> On 2019/12/12 13:40, Eliot Moss wrote:
> 
> > Ah!  I think what you want is a tmpfs or ramfs.
> > Not sure if cygwin supports that ...
> >   
> ----
>     Easiest thing might be to use /dev/shm. I used it during
> development to store intermediate data that was later to be
> transfered via a fifo...
> 
> Basically check for existence of "/dev/shm" (exists on my cygwin).
> if "tmp" didn't already exist, create it w/options similar to
> /tmp (only owner can delete/edit):
> 
> mkdir -m 1777 /tmp/shm/tmp
> 
> 
> **Warning, "writes" to /dev/shm/tmp (or /dev/mem) can fill up
> your system's memory, so its only good for "small files"
> (small being well under your system's free memory amount).

This is true for Linux, but not for cygwin, where /dev/shm is ntfs on disk: 

~: uname -a
CYGWIN_NT-10.0 VD-TIK-12 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
~: df -TH /dev/shm

Filesystem     Type  Size  Used Avail Use% Mounted on
C:/cygwin64    ntfs   34G   25G  8.9G  74% /

Its content is still there after a reboot and I can see it with the windows
explorer:

https://fex.belwue.de/fop/dyQzlG1x/X-20191213103905.png


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<5DF2E42A.7020200@tlinx.org>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: non-persistant storage?
  2019-12-12 12:28 non-persistant storage? Ulli Horlacher
  2019-12-12 21:27 ` Eliot Moss
@ 2019-12-16 10:22 ` Corinna Vinschen
  1 sibling, 0 replies; 9+ messages in thread
From: Corinna Vinschen @ 2019-12-16 10:22 UTC (permalink / raw)
  To: Ulli Horlacher; +Cc: cygwin

[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]

Hi Ulli,

On Dec 12 13:00, Ulli Horlacher wrote:
> I need to store some data (a few kB) non-persistant.
> On a real UNIX I would use /var/run, because after a shutdown all its
> content is lost.
> But on cygwin /var/run is stored on disk.
> 
> I cannot use an environment variable, because different processes need to
> read/write the data.
> 
> /proc is non-persistant (in respect to a reboot), but It is not a generic
> storage place.
> 
> What can I use with cygwin instead?
> 
> Installing third party software is not an option, it must work with a
> standard Windows (and cygwin).

Cygwin is just a user space DLL, it's not an OS.  Creating RAM disk-like
storage is the job of the OS or an OS driver.  Unfortunately, there's no
onboard RAM disk driver in Windows, just zillions of third-party solutions.

I see two options:

- Use XSI shared memory, as outlined in this thread already, or

- If you have the executables under source control, you can use
  an O_TMPFILE on /dev/shm, and fork the worker process from there,
  i.e.

    fd = open ("/dev/shm", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);
    if (fd >= 0)
      {
	write (fd, your_key, strlen (your_key));
	switch (fork ())
	  {
	  case 0: /* child */
	    /* Use fd as you see fit */
	    break;
	  case -1: /* error */
	  default: /* parent */
	    close (fd);
	    wait (&status);
	    break;
	  }
      }


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-12-16 10:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12 12:28 non-persistant storage? Ulli Horlacher
2019-12-12 21:27 ` Eliot Moss
2019-12-12 21:40   ` Ulli Horlacher
2019-12-12 21:59     ` Eliot Moss
2019-12-13  1:33       ` L A Walsh
2019-12-13  6:28         ` Brian Inglis
2019-12-13  9:34           ` L A Walsh
2019-12-13 10:06         ` Ulli Horlacher
2019-12-16 10:22 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).