/***************************************************************************** * Driver tty interface functions *****************************************************************************/ static int serial_open (struct tty_struct *tty, struct file * filp) { struct usb_serial *serial; struct usb_serial_port *port; int portNumber; dbg(__FUNCTION__); /* initialize the pointer incase something fails */ tty->driver_data = NULL; /* get the serial object associated with this tty pointer */ serial = get_serial_by_minor (MINOR(tty->device)); if (serial_paranoia_check (serial, __FUNCTION__)) { return -ENODEV; } /* set up our port structure making the tty driver remember our port object, and us it */ portNumber = MINOR(tty->device) - serial->minor; port = &serial->port[portNumber]; tty->driver_data = port; port->tty = tty; /* pass on to the driver specific version of this function if it is available */ if (serial->type->open) { return (serial->type->open(port, filp)); } else { return (generic_open(port, filp)); } }
int pvfsopen( pfile * pf,char * file_name , char *mode) { int ret = 0 ; //file_object src; memset(pf, 0 , sizeof(struct file_object_s)); resolve_filename(pf, file_name); if ('r' == *mode) { ret=generic_open(pf, &credentials,0,0,NULL,OPEN_SRC); } if('w' == *mode) { ret=generic_open(pf, &credentials,0,0,NULL,OPEN_DEST); } if( ret < 0) { fprintf(stderr, "Could not open"); return (-1); } }
/***************************************************************************** * Driver tty interface functions *****************************************************************************/ static int serial_open (struct tty_struct *tty, struct file * filp) { struct usb_serial *serial; struct usb_serial_port *port; unsigned int portNumber; int retval = 0; dbg("%s", __FUNCTION__); /* initialize the pointer incase something fails */ tty->driver_data = NULL; /* get the serial object associated with this tty pointer */ serial = get_serial_by_minor (MINOR(tty->device)); if (serial_paranoia_check (serial, __FUNCTION__)) return -ENODEV; /* set up our port structure making the tty driver remember our port object, and us it */ portNumber = MINOR(tty->device) - serial->minor; port = &serial->port[portNumber]; tty->driver_data = port; down (&port->sem); port->tty = tty; /* lock this module before we call it */ if (serial->type->owner) __MOD_INC_USE_COUNT(serial->type->owner); ++port->open_count; if (port->open_count == 1) { /* only call the device specific open if this * is the first time the port is opened */ if (serial->type->open) retval = serial->type->open(port, filp); else retval = generic_open(port, filp); } if (retval) { port->open_count = 0; if (serial->type->owner) __MOD_DEC_USE_COUNT(serial->type->owner); } up (&port->sem); return retval; }