This commit is contained in:
Pavel 2023-11-02 15:59:28 +03:00
parent c9a1f2cd94
commit f236d00b83
5 changed files with 43 additions and 33 deletions

View File

@ -78,7 +78,7 @@ end;
}
function fdesc_cmount(ma,data:Pointer;flags:QWORD):Integer;
begin
Exit(kernel_mount(ma, flags));
Exit(kernel_nmount(ma, flags));
end;
{

View File

@ -98,7 +98,7 @@ function mount_argsu(ma:p_mntarg;name:PChar;val:Pointer;len:Integer):p_mntarg;
function mount_arg(ma:p_mntarg;name:PChar;val:Pointer;len:Integer):p_mntarg;
procedure free_mntarg(ma:p_mntarg);
function kernel_mount(ma:p_mntarg;flags:QWORD):Integer;
function kernel_nmount(ma:p_mntarg;flags:QWORD):Integer;
function kern_unmount(path:PChar;flags:Integer):Integer;
function sys_nmount(iovp:Pointer;iovcnt:DWORD;flags:QWORD):Integer;
@ -1566,10 +1566,14 @@ begin
// vfs_setpublicfs(nil, nil, nil);
vfs_msync(mp, MNT_WAIT);
MNT_ILOCK(mp);
async_flag:=mp^.mnt_flag and MNT_ASYNC;
mp^.mnt_flag:=mp^.mnt_flag and (not MNT_ASYNC);
mp^.mnt_flag :=mp^.mnt_flag and (not MNT_ASYNC);
mp^.mnt_kern_flag:=mp^.mnt_kern_flag and (not MNTK_ASYNC);
MNT_IUNLOCK(mp);
//cache_purgevfs(mp); { remove cache entries for this file sys }
//vfs_deallocate_syncvnode(mp);
@ -1796,13 +1800,13 @@ end;
{
* Mount a filesystem
}
function kernel_mount(ma:p_mntarg;flags:QWORD):Integer;
function kernel_nmount(ma:p_mntarg;flags:QWORD):Integer;
var
auio:t_uio;
error:Integer;
begin
Assert(ma<>nil, 'kernel_mount nil ma');
Assert(ma^.v<>nil, 'kernel_mount nil ma^.v');
Assert(ma<>nil, 'kernel_mount nil ma');
Assert(ma^.v<>nil, 'kernel_mount nil ma^.v');
Assert((ma^.len and 1)=0, 'kernel_mount odd ma^.len (%d)');
auio.uio_iov:=ma^.v;

View File

@ -10,7 +10,9 @@ uses
vmount;
procedure vfs_mountroot();
function vfs_mountroot_simple(fstype,fspath,from,opts:PChar;flags:QWORD):Integer;
function vfs_mount_path (fstype,fspath,from,opts:PChar;flags:QWORD):Integer;
function vfs_mount_mkdir (fstype,fspath,from,opts:PChar;flags:QWORD):Integer;
function vfs_unmount_rmdir(path:PChar;flags:Integer):Integer;
implementation
@ -319,7 +321,7 @@ begin
Exit(0);
end;
function vfs_mountroot_simple(fstype,fspath,from,opts:PChar;flags:QWORD):Integer;
function vfs_mount_path(fstype,fspath,from,opts:PChar;flags:QWORD):Integer;
const
ERRMSGL=255;
var
@ -343,7 +345,25 @@ begin
ma:=mount_arg(ma, 'errmsg', PChar(errmsg), ERRMSGL);
ma:=parse_mountroot_options(ma, opts);
Result:=kernel_mount(ma,flags);
Result:=kernel_nmount(ma,flags);
end;
function vfs_mount_mkdir(fstype,fspath,from,opts:PChar;flags:QWORD):Integer;
begin
Result:=kern_mkdir(fspath,UIO_SYSSPACE,&777);
if (Result=0) then
begin
Result:=vfs_mount_path(fstype,fspath,from,opts,flags);
end;
end;
function vfs_unmount_rmdir(path:PChar;flags:Integer):Integer;
begin
Result:=kern_unmount(path,flags);
if (Result=0) then
begin
Result:=kern_rmdir(path,UIO_SYSSPACE);
end;
end;
procedure vfs_mountroot();
@ -360,39 +380,24 @@ begin
mount_print;
error:=vfs_mountroot_simple('ufs','/','/',nil,MNT_ROOTFS);
error:=vfs_mount_path('ufs','/','/',nil,MNT_ROOTFS);
if (error<>0) then goto _end;
//error:=vfs_mountroot_simple('devfs','/dev','/dev',nil,MNT_ROOTFS);
//if (error<>0) then goto _end;
mount_print;
error:=vfs_mountroot_shuffle(mp);
//error:=vfs_mountroot_simple('ufs','/app0/test','/app0/test',nil,0);
//if (error<>0) then goto _end;
{
error:=kern_mkdir('null',UIO_SYSSPACE,&777);
if (error=0) then
begin
error:=vfs_mountroot_simple('nullfs','/null','/dev',nil,0);
end;
}
error:=kern_mkdir('app0',UIO_SYSSPACE,&777);
if (error=0) then
begin
error:=vfs_mountroot_simple('ufs','/app0','/',nil,0);
end;
error:=kern_mkdir('system',UIO_SYSSPACE,&777);
if (error=0) then
begin
error:=vfs_mountroot_simple('ufs','/system','/system',nil,0);
end;
//error:=kern_unmount('/app0',0);
//error:=vfs_mount_mkdir('ufs','/app0','/',nil,0);
//error:=vfs_mount_mkdir('ufs','/system','/system',nil,0);
//
mount_print;
_end:

View File

@ -336,7 +336,7 @@ begin
if (mp^.mnt_stat.f_fsid.val[0]=fsid^.val[0]) and
(mp^.mnt_stat.f_fsid.val[1]=fsid^.val[1]) then
begin
MNT_REL(mp);
MNT_REF(mp);
mtx_unlock(mountlist_mtx);
Exit(mp);
end;
@ -849,8 +849,7 @@ var
active:Integer;
begin
mp:=vp^.v_mount;
if (mp=nil) then
Exit;
if (mp=nil) then Exit;
MNT_ILOCK(mp);
VI_LOCK(vp);
Assert(mp^.mnt_activevnodelistsize <= mp^.mnt_nvnodelistsize,

View File

@ -457,11 +457,13 @@ end;
procedure MNT_REF(mp:p_mount); inline;
begin
Assert(mp^.mnt_ref>=0);
System.InterlockedIncrement(mp^.mnt_ref);
end;
procedure MNT_REL(mp:p_mount); inline;
begin
Assert(mp^.mnt_ref>0);
if (System.InterlockedDecrement(mp^.mnt_ref)=0) then
begin
wakeup(mp)