Where does /etc map to on the host system under MSYS? - msys

I want to be sure that my changes to /etc will be persisted between restarts of MinGW. However, trying to write to /etc results in permission denied errors, so I am starting to think it is just mapped in memory and does not actually exist on the host file system at all but since I can't find any documentation about this I'd appreciate confirmation.

/etc is a real location that depends on a relative install directory. On my system, the location is:
C:\MinGW\msys\1.0\etc
Naturally, your install location may vary.
As you may recall, Windows has a propensity for locking directories when something running sees the folder as its working directory. It is very likely that permission denied errors are due to run-time state. If you wish to save/restore /etc, this probably must occur before any MSYS processes are running, or all MSYS processes that were already running need to be stopped.
A workaround for perpetually locked directories, when one cannot find/remove the "lock", is to rename the directory, copy in a new one, and delete the renamed copy after a reboot.

Related

How to change the tmp directory location in ember apps

Is there a way to change the location of the tmp directory ember-cli is using to process trees? (without using symlinks)
I am trying to develop an ember app using a linux VM on a windows host. Shared folders of any type (be it virtualbox shared folders, nfs or smb) are slow, don't allow symlinks and ember-cli produces a lot of files in the tmp directory. Being able to move this tmp to the native filesystem of the VM would help a lot.
This should be easily configurable, but i couldn't find any configuration option that would allow it.
No. Nobody answered and the help of the ember-cli build doesn't show that parameter.
How about creating a RAMDisk and hardlinking your project tmp folder to it? In Windows this can be done as follows:
Create RAM DISK with imdisk
mklink /j "C:\project\tmp\" "H:\ember-tmp" where C:\project is your local project folder and H: is your RAM Disk.
I'm afraid I don't know the Linux equivalents but it should be easy enough to find. Apparently this can roughly halve your build times with no chance of losing data.
Information sourced from https://emberjs-developer.quora.com/How-to-make-Ember-js-CLI-ember-s-32-times-faster and kudos to Stefan Penner for the suggestion.
Note the link folder MUST already exist before you run mklink otherwise you get the misleading message "Local volumes are required to complete the operation" and the link destination (junction folder) MUST NOT exist otherwise you get the message "Cannot create a file when that file already exists".
Note as of Ember 3.0 you can now change the cache by doing the below
BROCCOLI_PERSISTENT_FILTER_CACHE_ROOT=/path/to/my/other/tmp/
This will output the broccolli files to the path of your choosing. You will need to do the tidy up operation yourself on this custom path
More information here
https://github.com/stefanpenner/async-disk-cache/issues/35

VS2008 Build C++ Project on Network Drive

The short of it is, I have VMs for building different scenarios of software. I do not wish to snapshot the code as it is backup elsewhere so I am storing all my code on the host PC and only building/testing in VMs to save space. Unfortunately I am receiving program database update errors when I try to build from a location mapped to the host hdd.
I know there is nothing wrong with the C++ projects as they build fine if moved inside the VM.
I have tried:
-cleaning/rebuilding
-removing the debug/release folders entirely
-checking out a copy of the source onto the host drive from within the VM
*Even when the idb and pdb files that the compiler complains about are created by VS, the problem persists.
How can I stop these C2471 errors when building from a non-local drive?
Perhaps, problem in the files that was created by compiler at previus build. Try to remove Debug (or Release) folder and build project again.
I'm not entirely sure as to why, but the issue seems to be related to using shared folders in VirtualBox. If the folders are referenced via a direct UNC path to the host machine it appears to work fine, but accessing through a shared folder (mapped or unmapped to a drive letter) doesn't appear to have the correct permissions.

Location of config files in project c++

I was wondering whether there is a convention for storing config files in c++. At the moment I am storing the config files in the same directory as the source code that uses them. When building I make sure via the CMakeLists to copy them to the correct location so I can just access them in a relative way (e.g. "config.cfg" iso "/foo/bar/config.cfg) for convenience.
The practice for config files is non portable and operating system dependent. You have also to ask yourself if your configuration is defined per installation/system or per user.
In general, it is a very bad idea to store config in the same directory as your execuable, at least once the developpement is finished. In general executables may be shared between several users and should therefore for security reasons be located in directories that are write-protected for everybody but the system administrator.
For unix/linux, you could for example consider:
/etc or a subfolder thereof, if your configuration is per installed system,
~/ if it's user defined configuration. The usual practice would be to start the filename with a dot. This article will tell you more.
For windows systems, you should consider:
the usual approach now, goes to the registry. Of course, this uses the windows api and is fully non portable.
a subfolder of C:\ProgramData or C:\Users\All users\AppData\Local if your configuration is per installed system,
a subfolder of C:\Users\%USERNAME%\AppData\Local for the users's own configuration.
This SO questions shows how to find the right folders.

Program configuration data in Unix/Linux

What is recommended way to keep a user configuration data in Unix/Linux?
My programming language is C++. Configuration data will be kept in XML/text/binary format, I have no problem with handling such files. I want to know where can I keep them. For example, in the Windows OS configuration data may be kept in the Registry (old way) or in user application data directory. What about Linux?
I need read/write access to configuration files.
The concept of the registry is peculiar to Windows, and Microsoft once admitted to it being ill-conceived (see this, this, this, this (see #2), and this).
In Unix and Linux, configuration for system-wide programs is in /etc or maybe an application-specific subdirectory.
Per user configuration data are kept in the user's home directory in a hidden file—in text format—or an application-specific hidden directory in the user's home directory. The proper way to reference the home directory is through the environment variable HOME. Hidden files and directories are created by making . the first character of the name.
Examples for system-wide configuration is /etc/wgetrc and /etc/ssh/. Examples of per-user data are $HOME/.bashrc and $HOME/.mozilla/.
The XDG Base Directory Specification specifies where configuration and other files should be stored in Linux and other X-based operating systems:
http://freedesktop.org/wiki/Specifications/basedir-spec
This is the modern way, and may eventually reduce the dotfile mess in the typical user's home directory.
Dotfiles are the classic Unix solution. If you want to deal with reading/writing everything yourself, go for it.
However, most modern programs I use have used GConf for storing preferences. It makes a lot of things easier, both as a developer and as a user (and apparently as an administrator, but I have no experience there).
That depends a little on your flavor of Linux but as a general rule most programs have the system default configuration somewhere in /etc with .config files in your home directory that can override the defaults in the /etc dir.
Great point .config should be .[Name of config file]

Need a http server with some specific criteria

I've been looking for a webserver for my project but I haven't been able to satisfy myself. I need a http server that has support for compiled CGI scripts (exe), for Windows, and must be able to use relative paths. It would be a bonus if the server could be a minimal/lightweight as possible.
The hardest part in my search thus far is finding a server that supports both CGI and has relative path support. When I say relative path, I mean the server root directory. I want to be able to pack this along with my project and therefore the paths in the conf files cannot be absolute.
The only one I've gotten to satisfy every criteria is Abyss Web but their license is proprietary and only free for personal use.
EDIT:
I have found the error in my ways. I started the process via cmd at root. Thus the relative paths apache was using in the conf was relative to where I was, at root. By changing to the root dir and running the process there, everything works as gbjbaanb has mentioned. But I suppose the context of my question is may still be valid. If I were to run the server as a process in a my program (C# .NET), what would be the 'current directory' then? Would I have to make sure I've changed the current directory environment variable prior to launching it?
What's wrong with Apache? You can set DocumentRoot to any directory (though I've not tried it for Windows on C:)
It also does apply to the webserver root directory - don't begin the directive with a / and it works.
I've quickly booted up a mock version of the server that I'm supposed to use and it seems what gbjbaanb is valid for Windows as well. As with *nix, the relative paths work based on what the current directory is when apache is launched. So for Windows, just make sure to set the environment variable for the current directory to the one you want apache to be relative of. For .NET, you just set System.IO.Directory.SetCurrentDirectory() or System.Environment.CurrentDirectory appropriately. I suppose for *nix, you would either cd into the directory before running or use chroot.