/// <summary> /// Remounts the mount point. /// </summary> /// <param name="mnt">The mount point.</param> /// <param name="readOnly">if set to <c>true</c> the mount poine will be set to read-only.</param> public void RemountMountPoint(MountPoint mnt, bool readOnly) { String command = String.Format("mount -o {0},remount -t {1} {2} {3}", readOnly ? "ro" : "rw", mnt.FileSystem, mnt.Block, mnt.Name); this.ExecuteShellCommand(command, NullOutputReceiver.Instance); RefreshMountPoints( ); }
/// <summary> /// Mounts the specified device. /// </summary> /// <param name="mountPoint">The mp.</param> /// <param name="options">The options.</param> public void Mount(MountPoint mountPoint, String options) { mountPoint.ThrowIfNull("mountPoint"); Device.ThrowIfNull("Device"); CommandErrorReceiver cer = new CommandErrorReceiver(); Device.ExecuteShellCommand("mount {0} {4} -t {1} {2} {3}", cer, mountPoint.IsReadOnly ? "-r" : "-w", mountPoint.FileSystem, mountPoint.Block, mountPoint.Name, !String.IsNullOrEmpty(options) ? String.Format("-o {0}", options) : String.Empty); }
/// <summary> /// Remounts the mount point. /// </summary> /// <param name="mountPoint">the mount point</param> /// <param name="readOnly">if set to <c>true</c> the mount poine will be set to read-only.</param> /// <exception cref="IOException">Throws if the mount point does not exist.</exception> public void RemountMountPoint(String mountPoint, bool readOnly) { if (MountPoints.ContainsKey(mountPoint)) { MountPoint mnt = MountPoints[mountPoint]; RemountMountPoint(mnt, readOnly); } else { throw new IOException("Invalid mount point"); } }
/// <summary> /// Mounts the specified device. /// </summary> /// <param name="mp">The mp.</param> /// <param name="options">The options.</param> public void Mount(MountPoint mp, string options) { CommandErrorReceiver cer = new CommandErrorReceiver(); if (Device.BusyBox.Available) { Device.ExecuteShellCommand("busybox mount {0} {4} -t {1} {2} {3}", cer, mp.IsReadOnly ? "-r" : "-w", mp.FileSystem, mp.Block, mp.Name, !string.IsNullOrEmpty(options) ? string.Format("-o {0}", options) : string.Empty); } else { Device.ExecuteShellCommand("mount {0} {4} -t {1} {2} {3}", cer, mp.IsReadOnly ? "-r" : "-w", mp.FileSystem, mp.Block, mp.Name, !string.IsNullOrEmpty(options) ? string.Format("-o {0}", options) : string.Empty); } }
/// <summary> /// Processes the new lines. /// </summary> /// <param name="lines">The lines.</param> /// <workitem id="16001">Bug w/ MountPointReceiver.cs/ProcessNewLines()</workitem> protected override void ProcessNewLines(string[] lines) { Device.MountPoints.Clear(); foreach (var line in lines) { Match m = Regex.Match(line, RE_MOUNTPOINT_PATTERN, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); if (m.Success) { string block = m.Groups[1].Value.Trim().Replace("//", "/"); string name = m.Groups[2].Value.Trim(); string fs = m.Groups[3].Value.Trim(); bool ro = string.Compare("ro", m.Groups[4].Value.Trim(), false) == 0; MountPoint mnt = new MountPoint(block, name, fs, ro); // currently does not support multiple mounts to the same location... Device.MountPoints[name] = mnt; } } }
/// <summary> /// Processes the new lines. /// </summary> /// <param name="lines">The lines.</param> /// <workitem id="16001">Bug w/ MountPointReceiver.cs/ProcessNewLines()</workitem> protected override void ProcessNewLines(string[] lines) { this.Device.MountPoints.Clear(); lines.ForEach(line => { var m = line.Match(RE_MOUNTPOINT_PATTERN, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); if (m.Success) { string block = m.Groups[1].Value.Trim().Replace("//", "/"); string name = m.Groups[2].Value.Trim(); string fs = m.Groups[3].Value.Trim(); bool ro = string.Compare("ro", m.Groups[4].Value.Trim(), false) == 0; MountPoint mnt = new MountPoint(block, name, fs, ro); string key = name.Substring(1); // currently does not support multiple mounts to the same location... if (!this.Device.MountPoints.ContainsKey(name)) { this.Device.MountPoints.Add(name, mnt); } } }); /* * foreach ( var line in lines ) { * Match m = Regex.Match ( line, RE_MOUNTPOINT_PATTERN, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace ); * if ( m.Success ) { * String block = m.Groups[1].Value.Trim ( ).Replace ( "//", "/" ); * String name = m.Groups[2].Value.Trim ( ); * String fs = m.Groups[3].Value.Trim ( ); * bool ro = String.Compare ( "ro", m.Groups[4].Value.Trim ( ), false ) == 0; * MountPoint mnt = new MountPoint ( block, name, fs, ro ); * String key = name.Substring ( 1 ); * // currently does not support multiple mounts to the same location... * if ( !Device.MountPoints.ContainsKey ( name ) ) { * Device.MountPoints.Add ( name, mnt ); * } * } * }*/ }
/// <summary> /// Processes the new lines. /// </summary> /// <param name="lines">The lines.</param> /// <workitem id="16001">Bug w/ MountPointReceiver.cs/ProcessNewLines()</workitem> protected override void ProcessNewLines( string[] lines ) { Device.MountPoints.Clear ( ); lines.ForEach ( line => { var m = line.Match ( RE_MOUNTPOINT_PATTERN, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace ); if ( m.Success ) { String block = m.Groups[1].Value.Trim ( ).Replace ( "//", "/" ); String name = m.Groups[2].Value.Trim ( ); String fs = m.Groups[3].Value.Trim ( ); bool ro = String.Compare ( "ro", m.Groups[4].Value.Trim ( ), false ) == 0; MountPoint mnt = new MountPoint ( block, name, fs, ro ); String key = name.Substring ( 1 ); // currently does not support multiple mounts to the same location... if ( !Device.MountPoints.ContainsKey ( name ) ) { Device.MountPoints.Add ( name, mnt ); } } } ); /* foreach ( var line in lines ) { Match m = Regex.Match ( line, RE_MOUNTPOINT_PATTERN, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace ); if ( m.Success ) { String block = m.Groups[1].Value.Trim ( ).Replace ( "//", "/" ); String name = m.Groups[2].Value.Trim ( ); String fs = m.Groups[3].Value.Trim ( ); bool ro = String.Compare ( "ro", m.Groups[4].Value.Trim ( ), false ) == 0; MountPoint mnt = new MountPoint ( block, name, fs, ro ); String key = name.Substring ( 1 ); // currently does not support multiple mounts to the same location... if ( !Device.MountPoints.ContainsKey ( name ) ) { Device.MountPoints.Add ( name, mnt ); } } }*/ }
/// <include file='.\BusyBox.xml' path='/BusyBox/Install/*'/> public bool Install(String busybox) { busybox.ThrowIfNullOrWhiteSpace("busybox"); FileEntry bb = null; try { Device.ExecuteShellCommand(BUSYBOX_COMMAND, NullOutputReceiver.Instance); return(true); } catch { // we are just checking if it is already installed so we really expect it to wind up here. } try { MountPoint mp = Device.MountPoints["/data"]; bool isRO = mp.IsReadOnly; Device.RemountMountPoint(Device.MountPoints["/data"], false); FileEntry path = null; try { path = this.fileListingService.FindFileEntry(BUSYBOX_BIN); } catch (FileNotFoundException) { // path doesn't exist, so we make it. this.fileSystem.MakeDirectory(BUSYBOX_BIN); // attempt to get the FileEntry after the directory has been made path = this.fileListingService.FindFileEntry(BUSYBOX_BIN); } this.fileSystem.Chmod(path.FullPath, "0755"); String bbPath = LinuxPath.Combine(path.FullPath, BUSYBOX_COMMAND); this.fileSystem.Copy(busybox, bbPath); bb = this.fileListingService.FindFileEntry(bbPath); this.fileSystem.Chmod(bb.FullPath, "0755"); Device.ExecuteShellCommand("{0}/busybox --install {0}", new ConsoleOutputReceiver( ), path.FullPath); // check if this path exists in the path already if (Device.EnvironmentVariables.ContainsKey("PATH")) { var paths = Device.EnvironmentVariables["PATH"].Split(':'); var found = paths.Where(p => String.Compare(p, BUSYBOX_BIN, false) == 0).Count( ) > 0; // we didnt find it, so add it. if (!found) { // this doesn't seem to actually work Device.ExecuteShellCommand(@"echo \ Mad Bee buxybox >> /init.rc", NullOutputReceiver.Instance); Device.ExecuteShellCommand(@"echo export PATH={0}:\$PATH >> /init.rc", NullOutputReceiver.Instance, BUSYBOX_BIN); } } if (mp.IsReadOnly != isRO) { // Put it back, if we changed it Device.RemountMountPoint(mp, isRO); } Device.ExecuteShellCommand("sync", NullOutputReceiver.Instance); } catch (Exception) { throw; } CheckForBusyBox( ); return(true); }
/// <summary> /// Unmounts the specified mount point. /// </summary> /// <param name="mountPoint">The mountPoint.</param> /// <param name="options">The options.</param> public void Unmount(MountPoint mountPoint, String options) { mountPoint.ThrowIfNull("mountPoint"); Unmount(mountPoint.Name, options); }
/// <summary> /// Unmounts the specified mount point. /// </summary> /// <param name="mountPoint">The mountPoint.</param> public void Unmount(MountPoint mountPoint) { Unmount(mountPoint, String.Empty); }
/// <summary> /// Remounts the mount point. /// </summary> /// <param name="mnt">The mount point.</param> /// <param name="readOnly">if set to <c>true</c> the mount poine will be set to read-only.</param> public void RemountMountPoint(MountPoint mnt, bool readOnly) { String command = String.Format("mount -o {0},remount -t {1} {2} {3}", readOnly ? "ro" : "rw", mnt.FileSystem, mnt.Block, mnt.Name); this.ExecuteShellCommand(command, NullOutputReceiver.Instance); RefreshMountPoints(); }
/// <summary> /// Unmounts the specified mount point. /// </summary> /// <param name="mountPoint">The mountPoint.</param> /// <param name="options">The options.</param> public void Unmount( MountPoint mountPoint, String options ) { mountPoint.ThrowIfNull ( "mountPoint" ); Unmount ( mountPoint.Name, options ); }
/// <summary> /// Unmounts the specified mount point. /// </summary> /// <param name="mountPoint">The mountPoint.</param> public void Unmount( MountPoint mountPoint ) { Unmount ( mountPoint, String.Empty ); }
/// <summary> /// Mounts the specified device. /// </summary> /// <param name="mountPoint">The mp.</param> /// <param name="options">The options.</param> public void Mount( MountPoint mountPoint, String options ) { mountPoint.ThrowIfNull ( "mountPoint" ); Device.ThrowIfNull ( "Device" ); CommandErrorReceiver cer = new CommandErrorReceiver ( ); if ( Device.BusyBox.Available ) { Device.ExecuteShellCommand ( "busybox mount {0} {4} -t {1} {2} {3}", cer, mountPoint.IsReadOnly ? "-r" : "-w", mountPoint.FileSystem, mountPoint.Block, mountPoint.Name, !String.IsNullOrEmpty ( options ) ? String.Format ( "-o {0}", options ) : String.Empty ); } else { Device.ExecuteShellCommand ( "mount {0} {4} -t {1} {2} {3}", cer, mountPoint.IsReadOnly ? "-r" : "-w", mountPoint.FileSystem, mountPoint.Block, mountPoint.Name, !String.IsNullOrEmpty ( options ) ? String.Format ( "-o {0}", options ) : String.Empty ); } }
/// <summary> /// Unmounts the specified mount point. /// </summary> /// <param name="mp">The mountPoint.</param> /// <param name="options">The options.</param> public void Unmount(MountPoint mountPoint, string options) { Unmount(mountPoint.Name, options); }
/// <summary> /// Mounts the specified mount point. /// </summary> /// <param name="mountPoint">The mountPoint.</param> public void Mount(MountPoint mountPoint) { Mount(mountPoint, string.Empty); }