+#ifdef LOCKLIB
+ int result;
+ lock_file = malloc(strlen(dev) + 1);
+ if (lock_file == NULL)
+ {
+ novm("lock file name");
+ }
+ strcpy (lock_file, dev);
+ result = mklock (dev, (void *) 0);
+
+ if (result > 0)
+ {
+ syslog (LOG_NOTICE, "Device %s is locked by pid %d", dev, result);
+ free (lock_file);
+ lock_file = NULL;
+ result = -1;
+ }
+ else
+ {
+ if (result < 0)
+ {
+ syslog (LOG_ERR, "Can't create lock file %s", lock_file);
+ free (lock_file);
+ lock_file = NULL;
+ result = -1;
+ }
+ }
+ return (result);
+#else