Skip to content

Commit

Permalink
Change mkfs parameters,add switch for mkfs.{fstype} command
Browse files Browse the repository at this point in the history
  • Loading branch information
tmkasun committed Jun 25, 2014
1 parent 9cdc28a commit 04628e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/models/partition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def path
def mount label
label ||= self.kname
mount_point = File.join "/var/hda/files/drives/", label
unmount if mountpoint #Unmount from previous mount point
Diskwz.mount mount_point, self
end

Expand Down
16 changes: 11 additions & 5 deletions lib/diskwz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,18 @@ def mount mount_point, disk
end

def format disk, fstype
DebugLogger.info "|#{self.class.name}|>|#{__method__}|:Disk.kname = #{disk.kname}, fstype = #{fstype}"
fstype = "vfat" if fstype == "fat32" #TODO: mkfs.vfat: invalid option -- 'q'
quick_format = (fstype == "ntfs") ? "-f" : nil
command = "mkfs.#{fstype} "
params = "-q #{quick_format} -F #{disk.path}" #-F parameter to ignore warning and -q for quiet execution
DebugLogger.info "|#{self.class.name}|>|#{__method__}|:Format params = #{params}"
case fstype
when "ntfs"
params = " -q -f -F #{disk.path}" #-F parameter to ignore warning and -q for quiet execution
when "vfat"
params = " #{disk.path}"
when "ext3" , "ext4"
params = " -q -F #{disk.path}"
else
raise "#{fstype} Filesystem type not supported.Please re-try with diffrent filesystem."
end
DebugLogger.info "|#{self.class.name}|>|#{__method__}|:Disk.kname = #{disk.kname}, fstype = #{fstype} format params = #{params}"
mkfs = DiskCommand.new command, params
mkfs.execute
raise "Command execution error: #{mkfs.stderr.read}" if not mkfs.success?
Expand Down

0 comments on commit 04628e1

Please sign in to comment.