1#ifndef __DISK_TABLE_H__ 2#define __DISK_TABLE_H__ 3 4#include <sys/types.h> 5 6#include <errno.h> 7#include <unistd.h> 8 9#if defined(__GNUC__) || defined(HAS_LONG_LONG) 10typedef long long ext2_loff_t; 11#else 12typedef long ext2_loff_t; 13#endif 14 15extern ext2_loff_t ext2_llseek (unsigned int, ext2_loff_t, unsigned int); 16 17#ifdef __linux__ 18 19#ifdef HAVE_LLSEEK 20#include <syscall.h> 21 22#else /* HAVE_LLSEEK */ 23 24#if defined(__alpha__) || defined(__ia64__) 25 26#define my_llseek lseek 27 28#else 29#include <linux/unistd.h> /* for __NR__llseek */ 30 31static int _llseek (unsigned int, unsigned long, 32 unsigned long, ext2_loff_t *, unsigned int); 33 34static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high, 35 unsigned long, offset_low,ext2_loff_t *,result, 36 unsigned int, origin) 37 38static ext2_loff_t my_llseek (unsigned int fd, ext2_loff_t offset, 39 unsigned int origin) 40{ 41 ext2_loff_t result; 42 int retval; 43 44 retval = _llseek (fd, ((unsigned long long) offset) >> 32, 45 ((unsigned long long) offset) & 0xffffffff, 46 &result, origin); 47 return (retval == -1 ? (ext2_loff_t) retval : result); 48} 49 50#endif /* __alpha__ */ 51 52#endif /* HAVE_LLSEEK */ 53 54ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset, 55 unsigned int origin) 56{ 57 ext2_loff_t result; 58 static int do_compat = 0; 59 60 if (!do_compat) { 61 result = my_llseek (fd, offset, origin); 62 if (!(result == -1 && errno == ENOSYS)) 63 return result; 64 65 /* 66 * Just in case this code runs on top of an old kernel 67 * which does not support the llseek system call 68 */ 69 do_compat = 1; 70 /* 71 * Now try ordinary lseek. 72 */ 73 } 74 75 if ((sizeof(off_t) >= sizeof(ext2_loff_t)) || 76 (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) 77 return lseek(fd, (off_t) offset, origin); 78 79 errno = EINVAL; 80 return -1; 81} 82 83#else /* !linux */ 84 85ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset, 86 unsigned int origin) 87{ 88 if ((sizeof(off_t) < sizeof(ext2_loff_t)) && 89 (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) { 90 errno = EINVAL; 91 return -1; 92 } 93 return lseek (fd, (off_t) offset, origin); 94} 95 96#endif /* linux */ 97 98 99#define DEFAULT_SECTOR_SIZE 512 100#define MAX_SECTOR_SIZE 2048 101#define SECTOR_SIZE 512 /* still used in BSD code */ 102#define MAXIMUM_PARTS 60 103 104#define ACTIVE_FLAG 0x80 105 106#define EXTENDED 0x05 107#define WIN98_EXTENDED 0x0f 108#define LINUX_PARTITION 0x81 109#define LINUX_SWAP 0x82 110#define LINUX_NATIVE 0x83 111#define LINUX_EXTENDED 0x85 112 113#define IS_EXTENDED(i) \ 114 ((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED) 115 116#define SIZE(a) (sizeof(a)/sizeof((a)[0])) 117 118 119 120 121enum failure { usage, usage2, ioctl_error,unable_to_open, 122 unable_to_read, unable_to_seek, 123 unable_to_write, out_of_memory 124}; 125 126enum action {fdisk, require, try_only, create_empty}; 127 128struct geom { 129 unsigned int heads; 130 unsigned int sectors; 131 unsigned int cylinders; 132}; 133 134#define MAX_ATTACH_DEV 4 135#define MAX_MOUNT_VOL 8 136#define MAX_PORT1_MOUNT_VOL 8 137 138#define PROC_FLASH_0 "/proc/flash_sda" 139#define PROC_FLASH_1 "/proc/flash_sdb" 140#define PROC_FLASH_2 "/proc/flash_sdc" 141#define PROC_FLASH_3 "/proc/flash_sdd" 142#define PROC_FLASH_4 "/proc/flash_sde" 143 144#define PROC_HDD_0 "/proc/hdd_sda" 145#define PROC_HDD_1 "/proc/hdd_sdb" 146#define PROC_HDD_2 "/proc/hdd_sdc" 147#define PROC_HDD_3 "/proc/hdd_sdd" 148#define PROC_HDD_4 "/proc/hdd_sde" 149struct dev_list{ 150 char hdd_flag[16]; 151 char flash_flag[16]; 152 char media_flag[32]; 153 char dev_name[16]; 154 char share_name[12]; 155 int mounts; 156 int bad_dev; 157}; 158 159int DSK_MountUserDisk(struct dev_list *devices, int dev_no, int *total_mounts); 160int DSK_MountPort1UserDisk(int *bad_dev, char *share_name, int *total_mounts); 161int DSK_UnmountUserDisk(char *share_name, int dev_no); 162int isUserDisk(char *disk_name); 163void InitDev(struct dev_list *devices, int num); 164int get_free_space(char *mount_point,char* type,unsigned long *size,int *percent, unsigned long *total); 165int get_userdisk_detail(char *mount_point,char *type,unsigned long *size,unsigned long *cylinders,unsigned long *heads,unsigned long *sectors); 166int get_userdisk_type(int disk_no,char* type); 167int get_userdisk_info(char dev_name[16],unsigned long *size,unsigned long *cylinders,unsigned long *heads,unsigned long *sectors); 168#endif 169 170