#! /usr/bin/perl
# 
# $Id$
# Main page of 'My::Project::captive'
# Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; exactly version 2 of June 1991 is required
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


package project::captive::Index;
require 5.6.0;	# at least 'use warnings;' but we need some 5.6.0+ modules anyway
our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
our $CVS_ID=q$Id$;
use strict;
use warnings;

BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,<F>)[0]]}; eval "use lib '$top_dir'"; close F; }
use My::Web;
use My::Project;
use project::captive::ListItem;


my $W=My::Project->init_project(
		"__PACKAGE__"=>__PACKAGE__,
		"ListItem"=>\@project::captive::ListItem::ListItem,
		"head_css"=>"
.reqpkg { font-style: italic; }
.stuff  { font-style: italic; font-size: larger; margin-left: 20%; margin-right: 10%; }
.re     { font-style: italic; }
",
		);


print vskip("10ex")."<h1 align=\"center\">!!! DO NOT DISCLOSE - **************** !!!</h1>\n".vskip("10ex");

print <<"HERE";
<h1>The First Read/Write NTFS for Free Operating Systems</h1>
<h1>The First Free Microsoft Windows Kernel API Emulation</h1>
HERE

my @stuff=(
		"A lot of people claim themselves as Windows Programmers.\n"
				." Now I can finally join them - I also wrote my own Microsoft Windows.",
		"Why do they need ".a_href('http://www.winsupersite.com/reviews/winserver2k3_gold2.asp','5000 developers')
				." to write Microsoft Windows when it is just One Man Show task?",



		"My first Microsoft Windows program ever written? Some 'helloworld'?"
				." <span class=\"quote\">hal.dll</span>.",
		);

print "<p class=\"stuff\">$_</p>\n" for ($stuff[int rand @stuff]);
print vskip "3ex";


print <<'HERE';
<table border="1" align="center" style="text-align: center;"><tr><th>Distribution</th>
		<th>Installation Case #1<br />Filesystem and installer<br />(recommended)</th>
		<th>Installation Case #2<br />Manual installation<br />(filesystem, expert user)</th>
		<th>Installation Case #3<br />Command-line client<br />(no filesystem access)</th></tr>
HERE
my %pkg=(
		1=>[qw(captive captive-lufs captive-install lufs gnome-vfs-httpcaptive ntfsprogs ntfsprogs-gnomevfs)],
		2=>[qw(captive captive-lufs                 lufs)],
		3=>[qw(captive)],
		);
my %reqpkg=(
		1=>[qw(glib2 gnome-vfs2 ORBit2 libxml2 openssl popt          libgnomeui)],
		2=>[qw(glib2 gnome-vfs2 ORBit2 libxml2 openssl popt)],
		3=>[qw(glib2 gnome-vfs2 ORBit2 libxml2 openssl popt readline)],
		);
my %version=(
		map(($_=>["0.9","0"]),qw(captive captive-lufs captive-install)),
		"lufs"=>["0.9.6","1captive1"],
		"gnome-vfs-httpcaptive"=>["2.3.8captive2","0"],
		"ntfsprogs"=>["200309071734","1captive1"],
		"ntfsprogs-gnomevfs"=>["1.0.1","0"],
		);
my %has_rh8=(map(($_=>1),qw(
		gnome-vfs-httpcaptive
		captive
		captive-lufs
		captive-install
		)));
my %has_mdk91=(map(($_=>1),qw(
		gnome-vfs-httpcaptive
		lufs
		captive
		captive-lufs
		captive-install
		)));
my %has_devel=(map(($_=>1),qw(
		ntfsprogs
		)));
my %pkg_nosrc=(map(($_=>1),qw(
		captive-lufs
		captive-install
		)));
my @dist=(
		{
			"name"=>"Red Hat 9<br />Shrike i386",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					my $file="$pkg-$version_base-$version_ext.i386.rpm";
					my $r=a_href "dist/$file",$file;
					(my $filedev=$file)=~s/^\Q$pkg\E-/${pkg}-devel-/;
					$r.="<br />".a_href("dist/$filedev",$filedev) if $has_devel{$pkg};
					return $r;
				},
			},
		{
			"name"=>"Red Hat 8<br />Psyche i386",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					my $file="$pkg-$version_base-$version_ext".(!$has_rh8{$pkg} ? "" : "rh8").".i386.rpm";
					my $r=a_href "dist/$file",$file;
					(my $filedev=$file)=~s/^\Q$pkg\E-/${pkg}-devel-/;
					$r.="<br />".a_href("dist/$filedev",$filedev) if $has_devel{$pkg};
					if ($pkg eq "captive-install") {
						for (qw(libxml2-2.5.4-1.i386.rpm libxml2-python-2.5.4-1.i386.rpm)) {
							$r.="<br />".a_href('ftp://ftp.redhat.com/pub/redhat/linux/9/en/os/i386/RedHat/RPMS/'.$_,$_)." of Red Hat 9";
							}
						}
					return $r;
				},
			},
		{
			"name"=>"Mandrake 9.1<br />Bamboo i586",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					my $file="$pkg-$version_base-$version_ext".(!$has_mdk91{$pkg} ? ".i386.rpm" : "mdk91.i586.rpm");
					my $r=a_href "dist/$file",$file;
					(my $filedev=$file)=~s/^\Q$pkg\E-/${pkg}-devel-/;
					$r.="<br />".a_href("dist/$filedev",$filedev) if $has_devel{$pkg};
					return $r;
				},
			},
		{
			"name"=>"Red Hat .src.rpm<br />(of 9 - Shrike)",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg_nosrc{$pkg};
					my $file="$pkg-$version_base-$version_ext.src.rpm";
					return $file,$file;
				},
			},
		{
			"name"=>"Debian GNU/Linux<br />'unstable' i386",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					$version_ext=~s/^\d+//;
					my $file="${pkg}_$version_base".($version_ext=~/^\d+$/ ? "" : $version_ext)."_i386.deb";
					my $r=a_href "dist/$file",$file;
					(my $filedev=$file)=~s/^\Q$pkg\E_/${pkg}-dev_/;
					$r.="<br />".a_href("dist/$filedev",$filedev) if $has_devel{$pkg};
					return $r;
				},
			},
		{
			"name"=>"Debian GNU/Linux<br />sources",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg_nosrc{$pkg};
					$version_ext=~s/^\d+//;
					my $file="${pkg}_$version_base".($version_ext=~/^\d+$/ ? "" : $version_ext);
					return CGI::escapeHTML($file).":"
							.' '     .a_href("dist/$file.dsc",".dsc","size"=>0)
							.'&nbsp;'.a_href("dist/$file.tar.gz",".tar.gz");
				},
			},
		{
			"name"=>"Sources (.tar.gz)",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg_nosrc{$pkg};
					$version_ext=~s/^\d+//;
					my $file="$pkg-$version_base".($version_ext=~/^\d+$/ ? "" : $version_ext).".tar.gz";
					return $file,$file;
				},
			},
		);

for my $dist (@dist) {
	print "<tr>";
		print "<td>".$dist->{"name"}."</td>";
		for my $case (1,2,3) {
			print "<td>";
			print join("<br />",map({ my $pkg=$_;
				my($file,$text)=&{$dist->{"out"}}($pkg,@{$version{$pkg}});
				(!defined $text ? ($file) || () : (a_href("dist/$file",$text)));
				} @{$pkg{$case}}));
			print "</td>";
			}
	print "</tr>\n";
	}
print <<'HERE';
</table>
HERE

print vskip "3ex";

print <<"HERE";
<h1>Installation notes</h1>

<p>You should first run <b>captive-install-acquire</b> command to check your
available Microsoft Windows drivers versions. Now you can execute:</p>

<blockquote>
<p class="quote"># mount -t captive-ntfs /dev/hda1 /mnt/dosc</p>
</blockquote>

<h2>Package version conflicts</h2>

<dl>

<dt>@{[ a_href 'http://lufs.sourceforge.net/lufs/','lufs' ]}</dt>
<dd><p><b>'captive' version required</b>: Although you may already have the
original package installed you must replace it by the local 'captive'-marked
version containing some 'captive'-essential fixes and extensions.</p></dd>

<dt>@{[ a_href 'http://linux-ntfs.sourceforge.net/','ntfsprogs' ]}</dt>
<dd><p><b>Original version >=200309071734 sufficient</b>:
The package downloadable here has no code patches - you can freely use the
original version instead.  Unfortunately the last public release is
<b>1.7.1</b> while this project requires at least
@{[ a_href 'http://linux-ntfs.sourceforge.net/snapshots/','snapshot' ]} version
<b>@{[ a_href 'http://linux-ntfs.sourceforge.net/snapshots/ntfsprogs-200309071734.tar.bz2','200309071734' ]}</b>
which is not packaged (.rpm/.deb) yet. Packaged versions are provided here for
your convenience.</p></dd>

</dl>


<h2>LUFS kernel driver module</h2>

<p>@{[ a_href 'http://lufs.sourceforge.net/lufs/','LUFS' ]} (Linux Userland File
System) needs Linux kernel module driver (<i>lufs.o</i>) compatible with your
running Linux kernel. Binary driver is supplied already precompiled for many
Linux kernel versions in the binary packages above (<b>.i386.rpm</b> and
<b>_i386.deb</b> archives).</p>

<p>If you cannot <b>mount</b>(8) your NTFS filesystem you should run <span
class="quote">/usr/share/lufs/prepmod</span> to see the reasons. It is always
recommended to upgrade to the latest stable kernel supplied by your GNU/Linux
distribution vendor. You may need to install package
<b>kernel-source</b> (Red Hat) or <b>kernel-headers</b> (Debian) matching your
Linux kernel version (<b>rpm&nbsp;-q&nbsp;kernel</b>) and re-run <span
class="quote">/usr/share/lufs/prepmod</span>.</p>


<h2>The First Free Microsoft Windows Kernel API Emulation</h2>

<p>Compatibility with existing binary Microsoft Windows file system drivers was
reached. Microsoft Windows kernel system components required by these drivers
were analyzed and successfuly emulated in the GNU/Linux operating system.
Project brings Microsoft Windows kernel emulation framework to support even
other types Microsoft Windows drivers in the future.</p>

<dl>
	<dt>Emulation principle equivalent</dt>
	<dd>
		<p>@{[ a_href('http://www.winehq.com/','Wine Project') ]}</p>
		<p>No code could be shared - Wine emulates only Microsoft Windows userland.
		Filesystem drivers completely belong to Microsoft Windows kernelland.</p>
	</dd>

	<dt>Closed-source read-only-crippled @{[ '$0' ]} equivalent for Microsoft Windows</dt>
	<dd>
		<p>@{[ a_href('http://www.sysinternals.com/ntw2k/freeware/ntfswin98.shtml',
				'NTFS for Windows 98') ]}</p>
		<p>There is a @{[ a_href('http://www.sysinternals.com/images/screenshots/ntfs98ap.gif',
				'diagram') ]} showing exactly the principle of Captive NTFS project.
		There is apparently disabled read/write functionality in <i>NTFS for
		Windows 98</i> as the same company also sells the following product sharing
		the same codebase:</p>
	</dd>

	<dt>Closed-source read/write @{[ '$299' ]} equivalent for MS-DOS</dt>
	<dd>
		<p>@{[ a_href('http://www.winternals.com/products/repairandrecovery/ntfsdospro.asp',
				'NTFSDOS Professional') ]}</p>
		<p>This product is the most close equivalent to Captive NTFS but it is
		a commercial product, closed-source and it has filesystem interface only
		for MS-DOS.</p>
	</dd>

	<dt>The only real competition: Closed-source read/write @{[ '$299' ]} equivalent</dt>
	<dd>
		<p>@{[ a_href('http://www.vmware.com/download/workstation.html',
				'VMware Workstation') ]}</p>
		<p>Original Microsoft Windows operating system can be run inside a virtual
		machine running under GNU/Linux and share the read-write NTFS disk by using
		a network file sharing through a&nbsp;VMware virtual network card.</p>
		<p>You need @{[ '$299' ]} for this product and you need to
		give up your system security by running un@{[ a_href '#sandbox','sandbox' ]}ed
		closed-source program in your GNU/Linux.</p>
	</dd>
</dl>


<h2>Security</h2>

<p><b>Re: @{[ a_href 'http://linux-ntfs.sourceforge.net/info/ntfs.html#7.7',
		"7.7 Can't we write a wrapper for Windows' driver?" ]}</<b></p>

<p class="re">&gt; It sounds like a great idea, to start with, but there are numerous
problems.</p>

<p><span class="re">&gt; The largest technical problem is joining the Windows
system DLL to the Linux VFS. It could be done, but it wouldn't be pretty.</span><br />
Yep. :-)</p>

<p><span class="re">&gt; It would have to run as part of the kernel which would mean
that if it went wrong it could crash the machine. With no source, we might not
be able to work around the problem.</span><br />
<a name="sandbox">Nope</a>,
@{[ a_href('http://lufs.sourceforge.net/lufs/','Linux Userland File System (LUFS)') ]}
moves the filesystem implementation to UNIX userland where the Microsoft
Windows filesystem is completely unarmed by Captive jail of chroot(2),
setuid(2) and setrlimit(2). There only remains one narrow connection to the rest of
system (by CORBA/ORBit). The filesystem's life environment gets kill(2)ed when
UNIX is no longer satisfied with it. Safety similiar to
@{[ a_href('http://www.vmware.com/solutions/security.html','VMware sandbox') ]}.</p>

<p><span class="re">&gt; The next major problem is compati<!--orig. text typo-->bility.
Which version of the Windows system file would we use? Picking one would limit
its use, making the wrapper versatile for all of them would be a programming
nightmare.</span><br />
Microsoft Windows NTFS filesystem driver is capable of accessing older formats
of the filesystem. This project currently runs Microsoft Windows XP version,
porting to Microsoft Windows 2003 Server expected. (Microsoft Windows upgrades
NTFS disk filesystem to its own version during complete CD-ROM Microsoft
Windows system installation - such operation is not threat this project use.)</p>

<p><span class="re">&gt; And it gets worse. The legal implications of
distributing Windows systems files would cause problems.</span><br />
User must be careful to obey all licensing restrictions according to his
local country laws.<br />
<span class="re">&gt; Also the proprietary nature of the driver would mean that
the other kernel coders would not investigate any problems if someone had used
the NTFS wrapper.</span><br />
It does not apply to this project due to the implemented
@{[ a_href '#sandbox','filesystem separation' ]}.</p>

@{[ vskip "3ex" ]}

<h1>See also</h1>
<ul>
	<li>@{[ a_href('Preview.html.pl','Technology Preview') ]}</li>
	<li>@{[ a_href('doc/','Developer Documentation') ]}</li>
	<li>@{[ a_href('apiref/','API Reference Manual') ]} (fragment)</li>
	<li>
		@{[ a_href('http://cvs.jankratochvil.net/viewcvs/priv/captive/','CVS repository ViewCVS') ]}
		(@{[ a_href('http://cvs.jankratochvil.net/viewcvs/priv/reactos/?only_with_tag=captive','ReactOS branch part') ]})
		</li>
	<li>@{[ a_href('Thanks.html.pl','Thanks') ]}</li>
	<li>@{[ a_href('Resources.html.pl','Related Pages') ]}</li>
</ul>

@{[ vskip "3ex" ]}

<p class="stuff">
	Why did I install Microsoft Windows and wrote such disgusting piece of code?<br />
	I expect @{[ a_href($W->{"top_dir"}."/CV.html.pl","yet another challenging task") ]}, !
</p>
HERE


My::Web->footer();
