[Devel] Re: [RFC v14-rc2][PATCH 1/7] ipc: allow allocation of an ipc object with desired identifier
Serge E. Hallyn
serue at us.ibm.com
Thu Apr 2 15:49:17 PDT 2009
Quoting Oren Laadan (orenl at cs.columbia.edu):
>
>
> Serge E. Hallyn wrote:
> > Quoting Oren Laadan (orenl at cs.columbia.edu):
> >> -int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
> >> +int
> >> +ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size, int req_id)
> >> {
> >> uid_t euid;
> >> gid_t egid;
> >> + int lid = 0;
> >> int id, err;
> >>
> >> if (size > IPCMNI)
> >> @@ -268,28 +270,41 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
> >> if (ids->in_use >= size)
> >> return -ENOSPC;
> >>
> >> + if (req_id >= 0)
> >> + lid = ipcid_to_idx(req_id);
> >> +
> >> spin_lock_init(&new->lock);
> >> new->deleted = 0;
> >> rcu_read_lock();
> >> spin_lock(&new->lock);
> >>
> >> - err = idr_get_new(&ids->ipcs_idr, new, &id);
> >> + err = idr_get_new_above(&ids->ipcs_idr, new, lid, &id);
> >> if (err) {
> >> spin_unlock(&new->lock);
> >> rcu_read_unlock();
> >> return err;
> >> }
> >>
> >> + if (req_id >= 0) {
> >> + if (id != lid) {
> >> + idr_remove(&ids->ipcs_idr, id);
> >> + spin_unlock(&new->lock);
> >> + rcu_read_unlock();
> >> + return -EBUSY;
> >> + }
> >> + new->seq = req_id / SEQ_MULTIPLIER;
> >
> > Should this be
> >
> > new->seq = req_id % ids->seq_max;
> >
> > ?
>
> This is how the user-visible IPC id is constructed:
>
> static inline int ipc_buildid(int id, int seq)
> {
> return SEQ_MULTIPLIER * seq + id;
> }
>
> and I want to get the original 'seq' .... (the 'id' in this function is
> an in-kernel identifier)
Hmm, yeah, I guess... I misunderstood what seq was doing. In
fact, now I just don't understand what it's doing at all...
Weird.
> >> + } else {
> >> + new->seq = ids->seq++;
> >> + if (ids->seq > ids->seq_max)
> >> + ids->seq = 0;
> >> + }
> >> +
> >> ids->in_use++;
> >>
> >> current_euid_egid(&euid, &egid);
> >> new->cuid = new->uid = euid;
> >> new->gid = new->cgid = egid;
> >>
> >> - new->seq = ids->seq++;
> >> - if(ids->seq > ids->seq_max)
> >> - ids->seq = 0;
> >> -
> >
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list