]> git.neil.brown.name Git - history.git/commitdiff
Add mknod support
authorSteve French <stevef@stevef95.austin.ibm.com>
Thu, 10 Jul 2003 13:09:17 +0000 (06:09 -0700)
committerSteve French <cifs.adm@hostme.bitkeeper.com>
Thu, 10 Jul 2003 13:09:17 +0000 (06:09 -0700)
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/cifsproto.h
fs/cifs/cifssmb.c
fs/cifs/dir.c
fs/cifs/file.c
fs/cifs/inode.c

index 60e4629b1d6789eb8ed3c846787c59af508e610d..ef8d97bc68abffa7a14c87ea60ed86edbe310348 100644 (file)
@@ -301,6 +301,7 @@ struct inode_operations cifs_dir_inode_ops = {
 /*     revalidate:cifs_revalidate,   */
        .setattr = cifs_setattr,
        .symlink = cifs_symlink,
+       .mknod   = cifs_mknod,
 };
 
 struct inode_operations cifs_file_inode_ops = {
index 0c0d756c53ae6875b9b92613b72d243ca5f45af5..fee246c19c904a02894107ce5534beb49de87ee0 100644 (file)
@@ -50,6 +50,7 @@ extern int cifs_create(struct inode *, struct dentry *, int, struct nameidata *)
 extern struct dentry *cifs_lookup(struct inode *, struct dentry *, struct nameidata *);
 extern int cifs_unlink(struct inode *, struct dentry *);
 extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *);
+extern int cifs_mknod(struct inode *, struct dentry *, int, dev_t);
 extern int cifs_mkdir(struct inode *, struct dentry *, int);
 extern int cifs_rmdir(struct inode *, struct dentry *);
 extern int cifs_rename(struct inode *, struct dentry *, struct inode *,
index a5012a52d89044af9db762a43148633c46499912..4179a651a3b2fc36fd0bcf83d24280cefbd6069f 100644 (file)
@@ -155,7 +155,7 @@ extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
                         __u64 size, __u16 fileHandle,__u32 opener_pid, int AllocSizeFlag);
 extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
                        char *full_path, __u64 mode, __u64 uid,
-                       __u64 gid, const struct nls_table *nls_codepage);
+                       __u64 gid, dev_t dev, const struct nls_table *nls_codepage);
 
 extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
                        const char *newName,
index 5761b8349297d75d77223dfd0b5bda8639dfba1e..132609f415d39aa205e99eed76c7e8254eea75dd 100644 (file)
@@ -2299,7 +2299,7 @@ CIFSSMBSetTimes(int xid, struct cifsTconInfo *tcon, char *fileName,
 int
 CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
                    char *fileName, __u64 mode, __u64 uid, __u64 gid,
-                   const struct nls_table *nls_codepage)
+                   dev_t device, const struct nls_table *nls_codepage)
 {
        TRANSACTION2_SPI_REQ *pSMB = NULL;
        TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -2358,6 +2358,9 @@ CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
        pSMB->hdr.smb_buf_length += pSMB->ByteCount;
        data_offset->Uid = cpu_to_le64(uid);
        data_offset->Gid = cpu_to_le64(gid);
+       /* better to leave device as zero when it is  */
+       data_offset->DevMajor = cpu_to_le64(MAJOR(device));
+       data_offset->DevMinor = cpu_to_le64(MINOR(device));
        data_offset->Permissions = cpu_to_le64(mode);
        pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount);
        rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
index dc8e1271a9a0761cc0fd3b7e73dbdd0a783c27fd..0cad099716967aac85111ae1e5865743c276b820 100644 (file)
@@ -193,6 +193,43 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
        return rc;
 }
 
+int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t device_number) 
+{
+       int rc = -EPERM;
+       int xid;
+       struct cifs_sb_info *cifs_sb;
+       struct cifsTconInfo *pTcon;
+       char *full_path = NULL;
+       struct inode * newinode = NULL;
+
+       xid = GetXid();
+
+       cifs_sb = CIFS_SB(inode->i_sb);
+       pTcon = cifs_sb->tcon;
+
+       full_path = build_path_from_dentry(direntry);
+
+       if (pTcon->ses->capabilities & CAP_UNIX) {
+               rc = CIFSSMBUnixSetPerms(xid, pTcon,
+                       full_path, mode, current->euid, current->egid,
+                       device_number, cifs_sb->local_nls);
+               if(!rc) {
+                        rc = cifs_get_inode_info_unix(&newinode, full_path,
+                                                      inode->i_sb);
+                       direntry->d_op = &cifs_dentry_ops;
+                       if(rc == 0)
+                               d_instantiate(direntry, newinode);
+               }
+       }
+
+        if (full_path)
+                kfree(full_path);
+        FreeXid(xid);
+
+        return rc;
+}
+
+
 struct dentry *
 cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct nameidata *nd)
 {
index 423ac755e7e099b3cff45b1012f333f97eee21e1..af9091dd0ebb3c0fa6175996fd374ca8220cc4b9 100644 (file)
@@ -125,6 +125,7 @@ cifs_open(struct inode *inode, struct file *file)
                                        CIFSSMBUnixSetPerms(xid, pTcon, full_path, inode->i_mode,
                                                (__u64)-1, 
                                                (__u64)-1,
+                                               0 /* dev */,
                                                cifs_sb->local_nls);
                                else {/* BB implement via Windows security descriptors */
                        /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/
index 3d78ae445e3c3b536177ed3f17a51305a09b14d3..8da95697dcd7413cb5fb76b43d0609163ae1912f 100644 (file)
@@ -397,6 +397,7 @@ cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
                        CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
                                (__u64)-1,  
                                (__u64)-1,
+                               0 /* dev_t */,
                                cifs_sb->local_nls);
                else { /* BB to be implemented via Windows secrty descriptors*/
                /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/
@@ -702,7 +703,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs)
        if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX)
            && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))
                rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,
-                                   cifs_sb->local_nls);
+                               0 /* dev_t */, cifs_sb->local_nls);
        else if (attrs->ia_valid & ATTR_MODE) {
                if((mode & S_IWUGO) == 0) /* not writeable */ {
                        if((cifsInode->cifsAttrs & ATTR_READONLY) == 0)