3
# Licensed to the Apache Software Foundation (ASF) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The ASF licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS,
15
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
# See the License for the specific language governing permissions and
17
# limitations under the License.
18
FloppyDrive=`echo $QUERY_STRING | gawk 'BEGIN { FS = "&" } {for (i=1;i<=NF;i=i+1) print $i}' | awk -F'=' '/FloppyDrive/{print $2}' | sed "s/%2F/\//g"`
23
scanned_drives_count=0
26
echo "<td nowrap class=\"bodyText\">"
27
for drive in `ls /dev/fd?`
29
scanned_drives_count=`expr $scanned_drives_count + 1`
30
escaped_drive=`exec echo $drive | sed 's&/&\\\/&g'`
31
umount $drive &> /dev/null
32
if mount | grep $drive &> /dev/null
35
echo "<td nowrap class=\"bodyText\">"
36
mountDir=`mount | grep $drive | awk '{print $3}'`
37
if [ "$mountDir" = "$FloppyDrive" ];
39
echo " <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\" checked> Floppy - $drive mounted on $mountDir"
41
echo " <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\"> Floppy - $drive mounted on $mountDir"
43
mounted_drives=`expr $mounted_drives + 1`
47
drive_permissions=`exec awk "/$escaped_drive/{print $4}" /etc/fstab | awk '{print $4}' | gawk 'BEGIN { FS = "," } {for (i=1;i<=NF;i=i+1) print $i}' | grep -i "user"`
48
if [ -z "$drive_permissions" ]
50
owner_drive_permissions=`exec awk "/$escaped_drive/{print $4}" /etc/fstab | awk '{print $4}' | gawk 'BEGIN { FS = "," } {for (i=1;i<=NF;i=i+1) print $i}' | grep -i "owner"`
51
owner=`ls -l $drive | awk '{print $3}'`
52
if [ "$owner_drive_permissions" -a $owner = "inktomi" ]
54
drive_permissions=$owner_drive_permissions
59
if [ "$drive_permissions" ]
61
umount $drive &> /dev/null
62
mount $drive &> /dev/null
63
if mount | grep $drive &> /dev/null
66
echo "<td nowrap class=\"bodyText\">"
67
mountDir=`mount | grep $drive | awk '{print $3}'`
68
#echo " <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\"> Floppy - $drive mounted on $mountDir"
69
if [ "$mountDir" = "$FloppyDrive" ];
71
echo " <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\" checked> Floppy - $drive mounted on $mountDir"
73
echo " <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\"> Floppy - $drive mounted on $mountDir"
75
mounted_drives=`expr $mounted_drives + 1`
76
media_count=`expr $media_count + 1`
80
media_count=`expr $media_count + 1`
83
#media_count=`expr $media_count - 1`
84
permission_count=`expr $permission_count + 1`
89
if [ "$mounted_drives" -eq 0 -a "$media_count" -eq "$scanned_drives_count" ]
91
echo " No floppy drives found or you don't have permission to mount the disk"
92
elif [ "$mounted_drives" -eq 0 -a "$media_count" -ne 0 ]; then
93
echo " No media found in any of the scanned drives"
94
elif [ "$mounted_drives" -eq 0 -a "$permission_count" -eq "$scanned_drives_count" ]; then
95
echo " Mount access denied. Please mount and unmount the floppy manually"