Ticket #3: os_freebsd.patch

File os_freebsd.patch, 2.3 KB (added by Alex Samorukov, 11 years ago)

fix -d <type> on freebsd

  • os_freebsd.cpp

     
    7676// part of static data.
    7777struct freebsd_dev_channel *devicetable[FREEBSD_MAXDEV];
    7878
    79 // forward declaration
    80 // static int parse_ata_chan_dev(const char * dev_name, struct freebsd_dev_channel *ch);
    81 
    82 
    8379// Returns 1 if device not available/open/found else 0.  Also shifts fd into valid range.
    8480static int isnotopen(int *fd, struct freebsd_dev_channel** fdchan) {
    8581  // put valid "file descriptor" into range 0...FREEBSD_MAXDEV-1
     
    336332static const char * fbsd_dev_twa_ctrl = "twa";
    337333static const char * fbsd_dev_cciss = "ciss";
    338334
    339 int parse_ata_chan_dev(const char * dev_name, struct freebsd_dev_channel *chan) {
     335int parse_ata_chan_dev(const char * dev_name, struct freebsd_dev_channel *chan, const char * type) {
    340336  int len;
    341337  int dev_prefix_len = strlen(fbsd_dev_prefix);
    342338 
     339 
     340  // No Autodetection if device type was specified by user
     341  if (*type){
     342   if(!strcmp(type,"ata")) return CONTROLLER_ATA;
     343   if(!strcmp(type,"sat")) return CONTROLLER_SAT;
     344   if(!strcmp(type,"scsi")) goto handlescsi;
     345   if(hpt_hba(type)) return CONTROLLER_HPT;
     346   return CONTROLLER_UNKNOWN;
     347   // todo - add other types
     348  }
     349 
    343350  // if dev_name null, or string length zero
    344351  if (!dev_name || !(len = strlen(dev_name)))
    345352    return CONTROLLER_UNKNOWN;
     
    466473    return false;
    467474  }
    468475
    469   parse_ok = parse_ata_chan_dev(dev,fdchan);
    470  
     476  parse_ok = parse_ata_chan_dev(dev,fdchan,get_req_type());
     477
    471478  if (parse_ok == CONTROLLER_UNKNOWN) {
    472479    free(fdchan);
    473480    errno = ENOTTY;
     
    21162123
    21172124smart_device * freebsd_smart_interface::autodetect_smart_device(const char * name)
    21182125{
    2119   int guess = parse_ata_chan_dev(name,NULL);
     2126  int guess = parse_ata_chan_dev(name,NULL,"");
    21202127  unsigned short vendor_id = 0, product_id = 0, version = 0;
    21212128 
    21222129  switch (guess) {
     
    21592166      set_err(EINVAL, "Option -d 3ware,N (N=%d) must have 0 <= N <= 15", disknum);
    21602167      return 0;
    21612168    }
    2162     int contr = parse_ata_chan_dev(name,NULL);
     2169    int contr = parse_ata_chan_dev(name,NULL,"");
    21632170    if (contr != CONTROLLER_3WARE_9000_CHAR && contr != CONTROLLER_3WARE_678K_CHAR)
    21642171      contr = CONTROLLER_3WARE_678K;
    21652172     return new freebsd_escalade_device(this, name, contr, disknum);