proc->thread stage 4: rework the VFS and DEVICE subsystems to take thread
[dragonfly.git] / sys / vfs / nwfs / nwfs_subr.c
index c59ee25..6da1340 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/nwfs/nwfs_subr.c,v 1.2.2.2 2000/10/25 02:11:10 bp Exp $
- * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.c,v 1.2 2003/06/17 04:28:54 dillon Exp $
+ * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.c,v 1.3 2003/06/25 03:56:08 dillon Exp $
  */
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,7 +77,7 @@ ncp_update_file_info(struct nwmount *nmp, struct ncp_rq *rqp,
 }
 
 int
-ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred)
+ncp_initsearch(struct vnode *dvp,struct thread *td,struct ucred *cred)
 {
        struct nwmount *nmp = VTONWFS(dvp);
        struct ncp_conn *conn = NWFSTOCONN(nmp);
@@ -88,7 +88,7 @@ ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred)
        DECLARE_RQ;
 
        NCPNDEBUG("vol=%d,dir=%d\n", volnum, dirent);
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 2);            /* subfunction */
        ncp_rq_byte(rqp, nmp->name_space);
        ncp_rq_byte(rqp, 0);            /* reserved */
@@ -103,13 +103,13 @@ int
 ncp_search_for_file_or_subdir(struct nwmount *nmp,
                              struct nw_search_seq *seq,
                              struct nw_entry_info *target,
-                             struct proc *p,struct ucred *cred)
+                             struct thread *td,struct ucred *cred)
 {
        struct ncp_conn *conn = NWFSTOCONN(nmp);
        int error;
        DECLARE_RQ;
 
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 3);            /* subfunction */
        ncp_rq_byte(rqp, nmp->name_space);
        ncp_rq_byte(rqp, 0);            /* data stream */
@@ -134,7 +134,7 @@ ncp_search_for_file_or_subdir(struct nwmount *nmp,
 int 
 ncp_obtain_info(struct nwmount *nmp,  u_int32_t dirent,
                int namelen, char *path, struct nw_entry_info *target,
-               struct proc *p,struct ucred *cred)
+               struct thread *td,struct ucred *cred)
 {
        struct ncp_conn *conn=NWFSTOCONN(nmp);
        int error;
@@ -146,7 +146,7 @@ ncp_obtain_info(struct nwmount *nmp,  u_int32_t dirent,
                return EINVAL;
        }
        ns = (path == NULL || path[0] == 0) ? NW_NS_DOS : nmp->name_space;
-       NCP_RQ_HEAD(87, p, cred);
+       NCP_RQ_HEAD(87, td, cred);
        ncp_rq_byte(rqp, 6);                    /* subfunction */
        ncp_rq_byte(rqp, ns);
        ncp_rq_byte(rqp, ns);   /* DestNameSpace */
@@ -168,7 +168,7 @@ ncp_obtain_info(struct nwmount *nmp,  u_int32_t dirent,
  */
 int
 ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap,
-               struct proc *p,struct ucred *cred)
+               struct thread *td,struct ucred *cred)
 {
        struct nwmount *nmp;
        struct nwnode *dnp = VTONW(dvp);
@@ -185,10 +185,10 @@ ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap,
        if (len == 1 && name[0] == '.') {
                if (strcmp(dnp->n_name, NWFS_ROOTVOL) == 0) {
                        error = ncp_obtain_info(nmp, dnp->n_fid.f_id, 0, NULL,
-                               fap, p, cred);
+                               fap, td, cred);
                } else {
                        error = ncp_obtain_info(nmp, dnp->n_fid.f_parent, 
-                               dnp->n_nmlen, dnp->n_name, fap, p, cred);
+                               dnp->n_nmlen, dnp->n_name, fap, td, cred);
                }
                return error;
        } else if (len == 2 && name[0] == '.' && name[1] == '.') {
@@ -196,7 +196,7 @@ ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap,
                return EIO;
        } else {
                error = ncp_obtain_info(nmp, dnp->n_fid.f_id, 
-                       len, name, fap, p, cred);
+                       len, name, fap, td, cred);
        }
        return error;
 }
@@ -216,7 +216,7 @@ int
 ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen,
            char *name, int open_create_mode, u_int32_t create_attributes,
            int desired_acc_rights, struct ncp_open_info *nop,
-           struct proc *p,struct ucred *cred)
+           struct thread *td,struct ucred *cred)
 {
        
        struct ncp_conn *conn=NWFSTOCONN(nmp);
@@ -231,7 +231,7 @@ ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen
        if ((create_attributes & aDIR) != 0) {
                search_attribs |= SA_SUBDIR_FILES;
        }
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 1);/* subfunction */
        ncp_rq_byte(rqp, nmp->name_space);
        ncp_rq_byte(rqp, open_create_mode);
@@ -261,11 +261,11 @@ ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen
 }
 
 int
-ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct proc *p,struct ucred *cred) {
+ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct thread *td,struct ucred *cred) {
        int error;
        DECLARE_RQ;
 
-       NCP_RQ_HEAD(66,p,cred);
+       NCP_RQ_HEAD(66,td,cred);
        ncp_rq_byte(rqp, 0);
        ncp_rq_mem(rqp, (caddr_t)fh, 6);
        error = ncp_request(conn,rqp);
@@ -275,13 +275,13 @@ ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct proc *p,struct ucred *cr
 
 int
 ncp_DeleteNSEntry(struct nwmount *nmp, u_int32_t dirent,
-                       int namelen,char *name,struct proc *p,struct ucred *cred)
+                       int namelen,char *name,struct thread *td,struct ucred *cred)
 {
        int error;
        struct ncp_conn *conn=NWFSTOCONN(nmp);
        DECLARE_RQ;
 
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 8);            /* subfunction */
        ncp_rq_byte(rqp, nmp->name_space);
        ncp_rq_byte(rqp, 0);            /* reserved */
@@ -297,12 +297,12 @@ ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype,
        struct ncp_nlstables *nt,
        nwdirent fdir, char *old_name, int oldlen,
        nwdirent tdir, char *new_name, int newlen,
-       struct proc *p, struct ucred *cred)
+       struct thread *td, struct ucred *cred)
 {
        DECLARE_RQ;
        int error;
 
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 4);
        ncp_rq_byte(rqp, ns);
        ncp_rq_byte(rqp, 1);
@@ -328,7 +328,7 @@ int
 ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, 
                                u_int32_t info_mask,
                                struct nw_modify_dos_info *info,
-                               struct proc *p,struct ucred *cred)
+                               struct thread *td,struct ucred *cred)
 {
        struct nwnode *np=VTONW(vp);
        u_int8_t volnum = nmp->n_volume;
@@ -337,7 +337,7 @@ ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp,
        int             error;
        DECLARE_RQ;
 
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 7);    /* subfunction */
        ncp_rq_byte(rqp, nmp->name_space);
        ncp_rq_byte(rqp, 0);    /* reserved */
@@ -351,11 +351,11 @@ ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp,
 }
 
 int
-ncp_setattr(vp, vap, cred, procp)
+ncp_setattr(vp, vap, cred, td)
        struct vnode *vp;
        struct vattr *vap;
        struct ucred *cred;
-       struct proc *procp;
+       struct thread *td;
 {
        struct nwmount *nmp=VTONWFS(vp);
        struct nwnode *np=VTONW(vp);
@@ -366,10 +366,11 @@ ncp_setattr(vp, vap, cred, procp)
        DECLARE_RQ;
 
        if (vap->va_size != VNOVAL) {
-               error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0,
-                                                  AR_WRITE | AR_READ, &nwn,procp,cred);
+               error = ncp_open_create_file_or_subdir(
+                           nmp, vp, 0, NULL, OC_MODE_OPEN, 0,
+                           AR_WRITE | AR_READ, &nwn,td,cred);
                if (error) return error;
-               NCP_RQ_HEAD(73,procp,cred);
+               NCP_RQ_HEAD(73,td,cred);
                ncp_rq_byte(rqp, 0);
                ncp_rq_mem(rqp, (caddr_t)&nwn.fh, 6);
                ncp_rq_dword(rqp, htonl(vap->va_size));
@@ -377,7 +378,7 @@ ncp_setattr(vp, vap, cred, procp)
                checkbad(ncp_request(conn,rqp));
                np->n_vattr.va_size = np->n_size = vap->va_size;
                NCP_RQ_EXIT;
-               ncp_close_file(conn, &nwn.fh, procp, cred);
+               ncp_close_file(conn, &nwn.fh, td, cred);
                if (error) return error;
        }
        info_mask = 0;
@@ -392,7 +393,7 @@ ncp_setattr(vp, vap, cred, procp)
                ncp_unix2dostime(&vap->va_atime, nmp->m.tz, &info.lastAccessDate, NULL, NULL);
        }
        if (info_mask) {
-               error = ncp_modify_file_or_subdir_dos_info(nmp, vp, info_mask, &info,procp,cred);
+               error = ncp_modify_file_or_subdir_dos_info(nmp, vp, info_mask, &info,td,cred);
        }
        return (error);
 }
@@ -400,11 +401,11 @@ ncp_setattr(vp, vap, cred, procp)
 int
 ncp_get_volume_info_with_number(struct ncp_conn *conn, 
            int n, struct ncp_volume_info *target,
-           struct proc *p,struct ucred *cred) {
+           struct thread *td,struct ucred *cred) {
        int error,len;
        DECLARE_RQ;
 
-       NCP_RQ_HEAD_S(22,44,p,cred);
+       NCP_RQ_HEAD_S(22,44,td,cred);
        ncp_rq_byte(rqp,n);
        checkbad(ncp_request(conn,rqp));
        target->total_blocks = ncp_rp_dword_lh(rqp);
@@ -428,13 +429,13 @@ ncp_get_volume_info_with_number(struct ncp_conn *conn,
 
 int
 ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf,
-           struct proc *p,struct ucred *cred) {
+           struct thread *td,struct ucred *cred) {
        int error;
        u_int8_t ns;
        u_int16_t nscnt;
        DECLARE_RQ;
 
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 24);   /* Subfunction: Get Loaded Name Spaces */
        ncp_rq_word(rqp, 0);
        ncp_rq_byte(rqp, volume);
@@ -452,13 +453,13 @@ ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf,
 int
 ncp_lookup_volume(struct ncp_conn *conn, char *volname, 
                u_char *volNum, u_int32_t *dirEnt,
-               struct proc *p,struct ucred *cred)
+               struct thread *td,struct ucred *cred)
 {
        int error;
        DECLARE_RQ;
 
        NCPNDEBUG("looking up vol %s\n", volname);
-       NCP_RQ_HEAD(87,p,cred);
+       NCP_RQ_HEAD(87,td,cred);
        ncp_rq_byte(rqp, 22);   /* Subfunction: Generate dir handle */
        ncp_rq_byte(rqp, 0);    /* src name space */
        ncp_rq_byte(rqp, 0);    /* dst name space, always zero */