Mount EXT2 Filesystem to cygwin - filesystems

I have an external USB drive that is formatted as a Linux EXT2 filesystem. It has a lot of data on it and I don't want to format the drive. I do the drive with a drive letter assign in Windows Explorer, but I am not able to open it. I can read the contents using the diskInternals Linux Reader application. What I want to do is to see this drive in Cygwin. When I execute df in Cygwin I see many of my drives listed, but not the EXT2 drive. How do I see this drive in Cygwin?

CYGWIN is a user space program. It is not a able to mount different filesystem not recognized by Windows.
Third party program could be able or you can use WSL

Related

How can I create a bootable dvd with custom DOS boot script?

We have a bootable USB stick that works perfectly. It will boot, ask the user for some options, then write files to the hard drive accordingly. We did this by using rufus-2.1, throwing freedos into the USB stick, and basically hijacking autoexec.bat. Autoexec.bat now executes some separate .bat scripts based on user input.
The problem is, we now want to have an option to allow users to burn an iso to a cd or dvd. We've been trying to create an image of the USB stick and burn it to a DVD.
We found plenty of information on this subject, but nothing has worked. We started by extracting the bootimage from various bootable iso files using imgburn. None of these worked. We tried extracting the bootimage from our USB stick, and that also didn't work.
Next we tried WinImage. We extracted the boot information from boot98.exe, hijacked autoexec.exe, created a new image and injected the files. We saved the files as a bootimage and tried the above method again, which also didn't work.
Is there perhaps a more straightforward way to execute DOS .bat scripts through cd/dvd boot? We'd be open to something other than DOS as well, as long as it can write files to a hard drive based on user input through a simple boot interface.
Note: The computer itself does not contain an operating system.
Thanks.
We found a very slick setup that does what we need. Unfortunately, the CD-ROM drivers do not work properly on modern DVD drives. Using this method, it should be possible to put all the scripts directly in autoexec.bat and run commands directly on the "simulated" floppy drive. For whatever reason, we can boot from the "floppy" section of the CD-ROM, but it cannot copy files from A: to C:. I believe we are very close, but no cigar.
http://www.hiren.info/pages/bootablecd
First method that actually produced a bootable CD and allowed scripts to be run by a choice entered by the user.

Running programs on another computer in C

I am making an FTP in C for learning purposes. I know how to connect to a computer and read/write a file, but I'm having problems with running programs. My idea is to connect to the computer, cd into a directory called Available and run ls -l or dir depending on what type of operating system the computer the client has connected to has. After I run one of the commands I want to be able to list the results on the client's computer. My question is, is this possible and if so what would I do? Thank you for reading.
Don't run console commands like that. Use the operating system's API / system calls to enumerate files in the current directory.
Windows: FindFirst/FindNextFile APIs
Linux: http://www.cs.cf.ac.uk/Dave/C/node20.html#SECTION002000000000000000000 <-- this should help for linux

How to determine if a file is on a FAT system (to see if it really is executable)

I am working at an OS independent file manager, and I divide files in groups, usually based on the extension. On Linux, I check if a file has the executable permissions or not, and if it does, I add it to the executables group.
This works great for Windows or Linux, but if you combine them it doesn't work so well. For example, while using it on Linux and exploring a windows mounted drive, all the files appear to be executable. I am trying to find a way to ignore those files and not add them to the executables group.
My code (on Linux) uses stat:
#ifndef WINDOWS
stat(ep->d_name, &buf);
....
if(!files_list[i].is_dir && buf.st_mode & 0111)
files_list[i].is_exe=1;
#endif
The first part of the answer is to find what filesystem the file is mounted on. To do that you need to find the filesystem using the st_dev field of the stat information for the file. (You can also do this by checking the file path, but you then have to check every path element for symbolic links).
You can then cross-reference the st_dev field with the mount table in /proc/mounts using getmntent_r(). There's an example of that in a previous answer. The mnt_type field will give you the text of the filesystem type, and you'll need to compare the string with a list of Windows filesystems.
Once you've found the filesystem, the only way to identify an executable is by heuristics. As other people have suggested, you can look at the file extension for Windows executables, and look at the initial bytes of the file for Linux executables. Don't forget executable scripts with the #! prefix, and you may need to read into a Jar file to find out if it contains an executable static main() method.
If you are browsing Windows files then you need to apply Windows rules for whether or not a file is executable. If the file extension is .EXE, .COM, .BAT, or .CMD then it is executable. If you want a more complete list then you should check MSDN. Note that it is possible to add registry entries on a machine that makes any extension you want to be considered executable, but it is best to ignore that kind of thing when you are browsing a drive from the network.
The fact is that you are fighting an uphill battle. The reason all the files have executable permissions is that the windows filesystem driver on Linux allows you to specify that as an option. This masks whether or not any files are Linux exceutables, for instance.
However, you could look into the file header for EVERY file and see if it is a Linux ELF executable (just like the Linux file command does).
It might be helpful to start by checking all the information about mounted filesystems so that you know what you are dealing with. For instance, do you have a CIFS filesystem mounted that is actually a Linux filesystem served up by SAMBA? If you enumerate every bit of information available about the mounted filesystem plus the complete set of stat info, you can probably identify combinations that act as fingerprints of the different scenarios.
Another option I could imagine, is to call the file util, and depend on its output (maybe its enough to grep for the words executable / script). This util exist/is compileable for windows (basically it just checks for some magic bytes in the files), too.

Compiling applications from shared folders in a VM

I currently have many Linux VM's set up on VMware Workstation, there are some shared folders that contain source code that is held on the host computer. The issue I am having is that whenever I try to compile a file by using any compiler I get an Illegal seek error and file not recognized. Is there any way around this? I am using an Ubuntu 64-bit VM with Windows 7 as the host and the location of the shared files are on the Windows 7 hard drive.
I've run into a number of problems doing development over a network share in the past and suggest rather than sharing the files via SMB, you'll find more luck if you check in/out the files from a source control system (or simply copy them) so they're on a "local" drive on both the guest and host.

How to change to an external disk drive in C

Hi all I was wondering how (if possible) to change to an external HDD in C. I am writing a program that works with an external HDD.
Thanks much,
Mr. Man
Be wary of changing directory within a program - all that's usually needed is to open the files on the external device without actually changing directory to it.
However, on both Windows and Unix, the basic answer is via a 'change directory' operation. On Unix-like platforms, that is the 'chdir(2)' system call; your program should specify the name of the directory where the external hard disk is mounted, and then relative pathnames will write to appropriate locations on the disk (subject to the path name not containing too many "../" sequences).
On Windows, you would need to ensure you specify the drive letter as well as the path on the hard drive.

Resources