FYI

--
Damien Kick 

-----Original Message-----
From: Kick Damien-DKICK1 
Sent: Thursday, 10 February, 2005 09:48
To: 'Raymond Toy'
Subject: RE: unix-getgrgid


That did the trick...

--
Damien Kick 

-----Original Message-----
From: Raymond Toy [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 10 February, 2005 08:18
To: Kick Damien-DKICK1
Subject: Re: unix-getgrgid


>>>>> "Damien" == Kick Damien <[EMAIL PROTECTED]> writes:

    Damien> Somebody helped me realize what's wrong... the original code 
snippet's
    Damien> buffer was too small.

Interesting.  CMUCL currently uses a buffer size of 2048.  I guess this should 
be larger.  I get a value of 7296 as well.  As an experiment can you try this 
version of unix-getgrgid?

(in-package "UNIX")
(defun unix-getgrgid (gid)
  "Return a GROUP-INFO structure for the group identified by GID, or NIL if not 
found."
  (declare (type unix-gid gid))
  (with-alien ((buf (array c-call:char 7296))
               (group-info (struct group)))
    (let ((result
           (alien-funcall
            (extern-alien "getgrgid_r"
                          (function (* (struct group))
                                    c-call:unsigned-int
                                    (* (struct group))
                                    (* c-call:char)
                                    c-call:unsigned-int))
            gid
            (addr group-info)
            (cast buf (* c-call:char))
            7296)))
      (unless (zerop (sap-int (alien-sap result)))
        (make-group-info
         :name (string (cast (slot result 'gr-name) c-call:c-string))
         :password (string (cast (slot result 'gr-passwd) c-call:c-string))
         :gid (slot result 'gr-gid)
         :members (loop :with members = (slot result 'gr-mem)
                        :for i :from 0
                        :for member = (deref members i)
                        :until (zerop (sap-int (alien-sap member)))
                        :collect (string (cast member
                        c-call:c-string))))))))


I changed the buffer from 2048 to 7296.  This should work, I hope.

Ray


Reply via email to