static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp,
register struct SimpleLocks *alp, int onlymine,
int clid);
-static void DoLockWarning(void);
+static void DoLockWarning(afs_ucred_t * acred);
/* int clid; * non-zero on SGI, OSF, SunOS, Darwin, xBSD ** XXX ptr type */
flock->l_pid = getpid();
}
}
+#elif defined(UKERNEL)
+void
+lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid)
+{
+ if (slp) {
+ slp->pid = get_user_struct()->u_procp->p_pid;
+ } else {
+ flock->l_pid = get_user_struct()->u_procp->p_pid;
+ }
+}
#else
void
lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid)
#if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
#ifdef AFS_SGI64_ENV
afs_proc_t *procp = curprocp;
-#else /* AFS_SGI64_ENV */
+#elif defined(UKERNEL)
+ afs_proc_t *procp = get_user_struct()->u_procp;
+#else
afs_proc_t *procp = u.u_procp;
#endif /* AFS_SGI64_ENV */
#endif
}
}
} else if (avc->flockCount == -1) {
- afs_StoreAllSegments(avc, areq, AFS_ASYNC); /* fsync file early */
+ afs_StoreAllSegments(avc, areq, AFS_SYNC | AFS_VMSYNC); /* fsync file early */
avc->flockCount = 0;
/* And remove the (only) exclusive lock entry from the list... */
osi_FreeSmallSpace(avc->slocks);
(tc, code, &avc->f.fid, areq,
AFS_STATS_FS_RPCIDX_SETLOCK, SHARED_LOCK,
NULL));
+ if ((lockType == LockWrite) && (code == VREADONLY))
+ code = EBADF; /* per POSIX; VREADONLY == EROFS */
} else
/* XXX - Should probably try and log this when we're
* XXX - running with logging enabled. But it's horrid
/* warn a user that a lock has been ignored */
afs_int32 lastWarnTime = 0; /* this is used elsewhere */
+static afs_int32 lastWarnPid = 0;
static void
-DoLockWarning(void)
+DoLockWarning(afs_ucred_t * acred)
{
register afs_int32 now;
+ pid_t pid = MyPidxx2Pid(MyPidxx);
+ char *procname;
+
now = osi_Time();
AFS_STATCNT(DoLockWarning);
- /* check if we've already warned someone recently */
- if (now < lastWarnTime + 120)
- return;
+ /* check if we've already warned this user recently */
+ if (!((now < lastWarnTime + 120) && (lastWarnPid == pid))) {
+ procname = afs_osi_Alloc(256);
+
+ if (!procname)
+ return;
- /* otherwise, it is time to nag the user */
- lastWarnTime = now;
+ /* Copies process name to allocated procname, see osi_machdeps for details of macro */
+ osi_procname(procname, 256);
+ procname[255] = '\0';
+
+ /* otherwise, it is time to nag the user */
+ lastWarnTime = now;
+ lastWarnPid = pid;
#ifdef AFS_LINUX26_ENV
- afs_warn
- ("afs: byte-range locks only enforced for processes on this machine.\n");
+ afs_warnuser
+ ("afs: byte-range locks only enforced for processes on this machine (pid %d (%s), user %ld).\n", pid, procname, (long)afs_cr_uid(acred));
#else
- afs_warn
- ("afs: byte-range lock/unlock ignored; make sure no one else is running this program.\n");
+ afs_warnuser
+ ("afs: byte-range lock/unlock ignored; make sure no one else is running this program (pid %d (%s), user %ld).\n", pid, procname, afs_cr_uid(acred));
#endif
+ afs_osi_Free(procname, 256);
+ }
+ return;
}
#else
) {
#endif
- /* this next check is safer when left out, but more applications work
- * with it in. However, they fail in race conditions. The question is
- * what to do for people who don't have source to their application;
- * this way at least, they can get work done */
-#ifdef AFS_LINUX24_ENV
- if (af->l_len == OFFSET_MAX)
- af->l_len = 0; /* since some systems indicate it as EOF */
-#else
- if (af->l_len == 0x7fffffff)
- af->l_len = 0; /* since some systems indicate it as EOF */
-#ifdef AFS_LINUX_64BIT_KERNEL
- if (af->l_len == LONG_MAX)
- af->l_len = 0; /* since some systems indicate it as EOF */
-#endif
-#endif
- /* Java VMs ask for l_len=(long)-1 regardless of OS/CPU; bottom 32 bits
- * sometimes get masked off by OS */
- if ((sizeof(af->l_len) == 8) && (af->l_len == 0x7ffffffffffffffeLL))
+ /* Java VMs ask for l_len=(long)-1 regardless of OS/CPU */
+ if ((sizeof(af->l_len) == 8) && (af->l_len == 0x7fffffffffffffffLL))
af->l_len = 0;
/* next line makes byte range locks always succeed,
* even when they should block */
if (af->l_whence != 0 || af->l_start != 0 || af->l_len != 0) {
- DoLockWarning();
+ DoLockWarning(acred);
code = 0;
goto done;
}