-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add other filesystem entries: sock, fifo, block, char
- Loading branch information
1 parent
4419f45
commit 6078819
Showing
8 changed files
with
377 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NyaFs.Processor.Scripting.Commands.Fs | ||
{ | ||
public class Block : ScriptStepGenerator | ||
{ | ||
public Block() : base("block") | ||
{ | ||
AddConfig(new ScriptArgsConfig(1, new ScriptArgsParam[] { | ||
new Params.FsPathScriptArgsParam(), | ||
new Params.NumberScriptArgsParam("major"), | ||
new Params.NumberScriptArgsParam("minor"), | ||
new Params.ModeScriptArgsParam(), | ||
new Params.NumberScriptArgsParam("user"), | ||
new Params.NumberScriptArgsParam("group") | ||
})); | ||
} | ||
|
||
public override ScriptStep Get(ScriptArgs Args) | ||
{ | ||
var A = Args.RawArgs; | ||
|
||
return new BlockScriptStep(A[0], Convert.ToUInt32(A[1]), Convert.ToUInt32(A[2]), Utils.ConvertMode(A[3]), Convert.ToUInt32(A[4]), Convert.ToUInt32(A[5])); | ||
} | ||
|
||
public class BlockScriptStep : ScriptStep | ||
{ | ||
string Path; | ||
uint User; | ||
uint Group; | ||
uint Mode; | ||
uint Major; | ||
uint Minor; | ||
|
||
public BlockScriptStep(string Path, uint Major, uint Minor, uint Mode, uint User, uint Group) : base("block") | ||
{ | ||
this.Path = Path; | ||
this.User = User; | ||
this.Group = Group; | ||
this.Mode = Mode; | ||
this.Major = Major; | ||
this.Minor = Minor; | ||
} | ||
|
||
public override ScriptStepResult Exec(ImageProcessor Processor) | ||
{ | ||
var Fs = Processor.GetFs(); | ||
// Проверим наличие загруженной файловой системы | ||
if (Fs == null) | ||
return new ScriptStepResult(ScriptStepStatus.Error, "Filesystem is not loaded"); | ||
|
||
if (Fs.Exists(Path)) | ||
{ | ||
var Item = Fs.GetElement(Path); | ||
if (Item.ItemType == Filesystem.Universal.Types.FilesystemItemType.Block) | ||
{ | ||
var File = Item as Filesystem.Universal.Items.Block; | ||
|
||
File.Mode = Mode; | ||
File.User = User; | ||
File.Group = Group; | ||
|
||
File.Major = Major; | ||
File.Minor = Minor; | ||
|
||
File.Modified = DateTime.Now; | ||
|
||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Block device {Path} updated!"); | ||
} | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"{Path} is not Block device!"); | ||
} | ||
else | ||
{ | ||
var Parent = Fs.GetParentDirectory(Path); | ||
if (Parent != null) | ||
{ | ||
var File = new Filesystem.Universal.Items.Block(Path, User, Group, Mode); | ||
|
||
File.Major = Major; | ||
File.Minor = Minor; | ||
|
||
Parent.Items.Add(File); | ||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Block device {Path} added!"); } | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"Parent dir for {Path} is not found!"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NyaFs.Processor.Scripting.Commands.Fs | ||
{ | ||
public class Char : ScriptStepGenerator | ||
{ | ||
public Char() : base("char") | ||
{ | ||
AddConfig(new ScriptArgsConfig(1, new ScriptArgsParam[] { | ||
new Params.FsPathScriptArgsParam(), | ||
new Params.NumberScriptArgsParam("major"), | ||
new Params.NumberScriptArgsParam("minor"), | ||
new Params.ModeScriptArgsParam(), | ||
new Params.NumberScriptArgsParam("user"), | ||
new Params.NumberScriptArgsParam("group") | ||
})); | ||
} | ||
|
||
public override ScriptStep Get(ScriptArgs Args) | ||
{ | ||
var A = Args.RawArgs; | ||
|
||
return new CharScriptStep(A[0], Convert.ToUInt32(A[1]), Convert.ToUInt32(A[2]), Utils.ConvertMode(A[3]), Convert.ToUInt32(A[4]), Convert.ToUInt32(A[5])); | ||
} | ||
|
||
public class CharScriptStep : ScriptStep | ||
{ | ||
string Path; | ||
uint User; | ||
uint Group; | ||
uint Mode; | ||
uint Major; | ||
uint Minor; | ||
|
||
public CharScriptStep(string Path, uint Major, uint Minor, uint Mode, uint User, uint Group) : base("char") | ||
{ | ||
this.Path = Path; | ||
this.User = User; | ||
this.Group = Group; | ||
this.Mode = Mode; | ||
this.Major = Major; | ||
this.Minor = Minor; | ||
} | ||
|
||
public override ScriptStepResult Exec(ImageProcessor Processor) | ||
{ | ||
var Fs = Processor.GetFs(); | ||
// Проверим наличие загруженной файловой системы | ||
if (Fs == null) | ||
return new ScriptStepResult(ScriptStepStatus.Error, "Filesystem is not loaded"); | ||
|
||
if (Fs.Exists(Path)) | ||
{ | ||
var Item = Fs.GetElement(Path); | ||
if (Item.ItemType == Filesystem.Universal.Types.FilesystemItemType.Character) | ||
{ | ||
var File = Item as Filesystem.Universal.Items.Char; | ||
|
||
File.Mode = Mode; | ||
File.User = User; | ||
File.Group = Group; | ||
|
||
File.Major = Major; | ||
File.Minor = Minor; | ||
|
||
File.Modified = DateTime.Now; | ||
|
||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Char device {Path} updated!"); | ||
} | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"{Path} is not Char device!"); | ||
} | ||
else | ||
{ | ||
var Parent = Fs.GetParentDirectory(Path); | ||
if (Parent != null) | ||
{ | ||
var File = new Filesystem.Universal.Items.Char(Path, User, Group, Mode); | ||
|
||
File.Major = Major; | ||
File.Minor = Minor; | ||
|
||
Parent.Items.Add(File); | ||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Char device {Path} added!"); } | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"Parent dir for {Path} is not found!"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NyaFs.Processor.Scripting.Commands.Fs | ||
{ | ||
public class Fifo : ScriptStepGenerator | ||
{ | ||
public Fifo() : base("fifo") | ||
{ | ||
AddConfig(new ScriptArgsConfig(1, new ScriptArgsParam[] { | ||
new Params.FsPathScriptArgsParam(), | ||
new Params.ModeScriptArgsParam(), | ||
new Params.NumberScriptArgsParam("user"), | ||
new Params.NumberScriptArgsParam("group") | ||
})); | ||
} | ||
|
||
public override ScriptStep Get(ScriptArgs Args) | ||
{ | ||
var A = Args.RawArgs; | ||
|
||
return new FifoScriptStep(A[0], Utils.ConvertMode(A[1]), Convert.ToUInt32(A[2]), Convert.ToUInt32(A[3])); | ||
|
||
} | ||
|
||
public class FifoScriptStep : ScriptStep | ||
{ | ||
string Path = null; | ||
uint User = uint.MaxValue; | ||
uint Group = uint.MaxValue; | ||
uint Mode = uint.MaxValue; | ||
|
||
public FifoScriptStep(string Path, uint Mode, uint User, uint Group) : base("fifo") | ||
{ | ||
this.Path = Path; | ||
this.User = User; | ||
this.Group = Group; | ||
this.Mode = Mode; | ||
} | ||
|
||
public override ScriptStepResult Exec(ImageProcessor Processor) | ||
{ | ||
var Fs = Processor.GetFs(); | ||
// Проверим наличие загруженной файловой системы | ||
if (Fs == null) | ||
return new ScriptStepResult(ScriptStepStatus.Error, "Filesystem is not loaded"); | ||
|
||
if (Fs.Exists(Path)) | ||
{ | ||
var Item = Fs.GetElement(Path); | ||
if (Item.ItemType == Filesystem.Universal.Types.FilesystemItemType.Fifo) | ||
{ | ||
var File = Item as Filesystem.Universal.Items.Fifo; | ||
|
||
File.Mode = Mode; | ||
File.User = User; | ||
File.Group = Group; | ||
|
||
File.Modified = DateTime.Now; | ||
|
||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Fifo {Path} updated!"); | ||
} | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"{Path} is not Fifo!"); | ||
} | ||
else | ||
{ | ||
var Parent = Fs.GetParentDirectory(Path); | ||
if (Parent != null) | ||
{ | ||
var File = new Filesystem.Universal.Items.Fifo(Path, User, Group, Mode); | ||
|
||
Parent.Items.Add(File); | ||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Fifo {Path} added!"); } | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"Parent dir for {Path} is not found!"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NyaFs.Processor.Scripting.Commands.Fs | ||
{ | ||
public class Sock : ScriptStepGenerator | ||
{ | ||
public Sock() : base("sock") | ||
{ | ||
AddConfig(new ScriptArgsConfig(1, new ScriptArgsParam[] { | ||
new Params.FsPathScriptArgsParam(), | ||
new Params.ModeScriptArgsParam(), | ||
new Params.NumberScriptArgsParam("user"), | ||
new Params.NumberScriptArgsParam("group") | ||
})); | ||
} | ||
|
||
public override ScriptStep Get(ScriptArgs Args) | ||
{ | ||
var A = Args.RawArgs; | ||
|
||
return new SockScriptStep(A[0], Utils.ConvertMode(A[1]), Convert.ToUInt32(A[2]), Convert.ToUInt32(A[3])); | ||
|
||
} | ||
|
||
public class SockScriptStep : ScriptStep | ||
{ | ||
string Path = null; | ||
uint User = uint.MaxValue; | ||
uint Group = uint.MaxValue; | ||
uint Mode = uint.MaxValue; | ||
|
||
public SockScriptStep(string Path, uint Mode, uint User, uint Group) : base("sock") | ||
{ | ||
this.Path = Path; | ||
this.User = User; | ||
this.Group = Group; | ||
this.Mode = Mode; | ||
} | ||
|
||
public override ScriptStepResult Exec(ImageProcessor Processor) | ||
{ | ||
var Fs = Processor.GetFs(); | ||
// Проверим наличие загруженной файловой системы | ||
if (Fs == null) | ||
return new ScriptStepResult(ScriptStepStatus.Error, "Filesystem is not loaded"); | ||
|
||
if (Fs.Exists(Path)) | ||
{ | ||
var Item = Fs.GetElement(Path); | ||
if (Item.ItemType == Filesystem.Universal.Types.FilesystemItemType.Socket) | ||
{ | ||
var File = Item as Filesystem.Universal.Items.Socket; | ||
|
||
File.Mode = Mode; | ||
File.User = User; | ||
File.Group = Group; | ||
|
||
File.Modified = DateTime.Now; | ||
|
||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Socket {Path} updated!"); | ||
} | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"{Path} is not Socket!"); | ||
} | ||
else | ||
{ | ||
var Parent = Fs.GetParentDirectory(Path); | ||
if (Parent != null) | ||
{ | ||
var File = new Filesystem.Universal.Items.Socket(Path, User, Group, Mode); | ||
|
||
Parent.Items.Add(File); | ||
return new ScriptStepResult(ScriptStepStatus.Ok, $"Socket {Path} added!"); } | ||
else | ||
return new ScriptStepResult(ScriptStepStatus.Error, $"Parent dir for {Path} is not found!"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.