示例#1
0
文件: unix.c 项目: rajbot/gphoto
static int
gp_port_serial_unlock (GPPort *dev, const char *path)
{

#if defined(HAVE_TTYLOCK)
	if (ttyunlock ((char*) path)) {
		if (dev)
			gp_port_set_error (dev, _("Device '%s' could not be "
					   "unlocked."), path);
		return (GP_ERROR_IO_LOCK);
	}
#elif defined(HAVE_LOCKDEV)

	int pid;

	pid = dev_unlock (path, 0);
	if (pid) {
		if (dev) {
			if (pid > 0)
				gp_port_set_error (dev, _("Device '%s' could "
					"not be unlocked as it is locked by "
					"pid %d."), path, pid);
			else
				gp_port_set_error (dev, _("Device '%s' could "
					"not be unlocked (dev_unlock "
					"returned %d)"), path, pid);
		}
		return (GP_ERROR_IO_LOCK);
	}
#endif /* !HAVE_LOCKDEV */

	return (GP_OK);
}
示例#2
0
文件: updown.c 项目: hehaorong/hhr
void lockfile_remove(void)
{
  if (portfd_is_socket)
    return;

#if !HAVE_LOCKDEV
  if (lockfile[0])
    unlink(lockfile);
#else
  ttyunlock(dial_tty);
#endif
}
示例#3
0
bool KMobileDevice::unlockDevice(const QString &device)
{
#ifdef HAVE_BAUDBOY_H
  return ttyunlock(device.local8bit()) == EXIT_SUCCESS;
#else
# ifdef HAVE_LOCKDEV_H
  return 0 <= dev_unlock(device.local8bit(), getpid());
# else
  QStringList all = QStringList::split('/', device);
  if (!all.count()) return false;
  QString lockName = DEVICE_LOCK_PATH_PREFIX + all[all.count()-1];
  QFile file(lockName);
  if (!file.exists())
	return true;
  return file.remove();
# endif
#endif
}