Exemplo n.º 1
0
        /// <summary>
        /// Remounts the mount point.
        /// </summary>
        /// <param name="mnt">The mount point.</param>
        /// <param name="readOnly">if set to <see langword="true"/> 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, null);
            this.RefreshMountPoints();
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Remounts the mount point.
 /// </summary>
 /// <param name="mountPoint">the mount point</param>
 /// <param name="readOnly">if set to <see langword="true"/> 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 (this.MountPoints.ContainsKey(mountPoint))
     {
         MountPoint mnt = this.MountPoints[mountPoint];
         this.RemountMountPoint(mnt, readOnly);
     }
     else
     {
         throw new IOException("Invalid mount point");
     }
 }
Exemplo n.º 4
0
        /// <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(IEnumerable <string> lines)
        {
            this.Device.MountPoints.Clear();

            foreach (var line in lines)
            {
                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);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <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(IEnumerable<string> lines)
        {
            this.Device.MountPoints.Clear();

            foreach(var line in lines)
            {
                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);
                    }
                }
            }
        }
Exemplo n.º 6
0
Arquivo: Device.cs Projeto: vebin/madb
 /// <summary>
 /// Remounts the mount point.
 /// </summary>
 /// <param name="mnt">The mount point.</param>
 /// <param name="readOnly">if set to <see langword="true"/> 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, null);
     this.RefreshMountPoints();
 }
Exemplo n.º 7
0
        /// <include file='.\BusyBox.xml' path='/BusyBox/Install/*'/>
        public bool Install(String busybox)
        {
            busybox.ThrowIfNullOrWhiteSpace("busybox");

            FileEntry bb = null;

            try {
                Device.ExecuteShellCommand(BUSYBOX_COMMAND, null);
                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", null);
                        Device.ExecuteShellCommand(@"echo export PATH={0}:\$PATH >> /init.rc", null, BUSYBOX_BIN);
                    }
                }


                if (mp.IsReadOnly != isRO)
                {
                    // Put it back, if we changed it
                    Device.RemountMountPoint(mp, isRO);
                }

                Device.ExecuteShellCommand("sync", null);
            } catch (Exception) {
                throw;
            }

            CheckForBusyBox( );
            return(true);
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Unmounts the specified mount point.
 /// </summary>
 /// <param name="mountPoint">The mountPoint.</param>
 public void Unmount(MountPoint mountPoint)
 {
     Unmount(mountPoint, String.Empty);
 }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Unmounts the specified mount point.
 /// </summary>
 /// <param name="mountPoint">The mountPoint.</param>
 public void Unmount(MountPoint mountPoint)
 {
     Unmount(mountPoint, String.Empty);
 }