#!/usr/bin/perl

# /* LICENSE:
#   =========================================================================
#     CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
#     Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
#     School of Computer Science, Carnegie Mellon University
#     All rights reserved.
#   ========================================================================= */

my $pc_card=0;

#if(-e "/sbin/cardctl") {
#  $pc_card = 1;
#} else {
#  $pc_card = 0;
#}

$mounted=0;
open(MOUNT_OUT,"/bin/mount |");
while(<MOUNT_OUT>) {
  m&/memstick& && do {
    $mounted=1;
  };
}

if($mounted) {
  system("/bin/umount /memstick");
}

if($pc_card) {
  $stop_file = "/var/run/ejectd/1";
  if(-e $stop_file) {
    open(STOPPER,">$stop_file");
    printf STOPPER "stop\n";
    close(STOPPER);
  }
}
