Re: non-persistant storage?

2019-12-16 Thread Corinna Vinschen
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


signature.asc
Description: PGP signature


Re: non-persistant storage?

2019-12-13 Thread Ulli Horlacher
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:/cygwin64ntfs   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: horlac...@tik.uni-stuttgart.de
Allmandring 30aTel:++49-711-68565868
70569 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
REF:<5df2e42a.7020...@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



Re: non-persistant storage?

2019-12-12 Thread L A Walsh

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



Re: non-persistant storage?

2019-12-12 Thread Brian Inglis
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



Re: non-persistant storage?

2019-12-12 Thread L A Walsh

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



Re: non-persistant storage?

2019-12-12 Thread Eliot Moss

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



Re: non-persistant storage?

2019-12-12 Thread Ulli Horlacher
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: horlac...@tik.uni-stuttgart.de
Allmandring 30aTel:++49-711-68565868
70569 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
REF:<8905c7b6-b2e6-52bf-bcdd-66890db91...@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



Re: non-persistant storage?

2019-12-12 Thread Eliot Moss

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