hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/cifs/dir.c
....@@ -69,11 +69,10 @@
6969 return full_path;
7070
7171 if (dfsplen)
72
- strncpy(full_path, tcon->treeName, dfsplen);
72
+ memcpy(full_path, tcon->treeName, dfsplen);
7373 full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb);
74
- strncpy(full_path + dfsplen + 1, vol->prepath, pplen);
74
+ memcpy(full_path + dfsplen + 1, vol->prepath, pplen);
7575 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
76
- full_path[dfsplen + pplen] = 0; /* add trailing null */
7776 return full_path;
7877 }
7978
....@@ -126,7 +125,7 @@
126125 }
127126 rcu_read_unlock();
128127
129
- full_path = kmalloc(namelen+1, GFP_KERNEL);
128
+ full_path = kmalloc(namelen+1, GFP_ATOMIC);
130129 if (full_path == NULL)
131130 return full_path;
132131 full_path[namelen] = 0; /* trailing null */
....@@ -245,10 +244,8 @@
245244 *oplock = REQ_OPLOCK;
246245
247246 full_path = build_path_from_dentry(direntry);
248
- if (full_path == NULL) {
249
- rc = -ENOMEM;
250
- goto out;
251
- }
247
+ if (!full_path)
248
+ return -ENOMEM;
252249
253250 if (tcon->unix_ext && cap_unix(tcon->ses) && !tcon->broken_posix_open &&
254251 (CIFS_UNIX_POSIX_PATH_OPS_CAP &
....@@ -358,13 +355,10 @@
358355 if (!tcon->unix_ext && (mode & S_IWUGO) == 0)
359356 create_options |= CREATE_OPTION_READONLY;
360357
361
- if (backup_cred(cifs_sb))
362
- create_options |= CREATE_OPEN_BACKUP_INTENT;
363
-
364358 oparms.tcon = tcon;
365359 oparms.cifs_sb = cifs_sb;
366360 oparms.desired_access = desired_access;
367
- oparms.create_options = create_options;
361
+ oparms.create_options = cifs_create_options(cifs_sb, create_options);
368362 oparms.disposition = disposition;
369363 oparms.path = full_path;
370364 oparms.fid = fid;
....@@ -417,6 +411,7 @@
417411 rc = cifs_get_inode_info_unix(&newinode, full_path, inode->i_sb,
418412 xid);
419413 else {
414
+ /* TODO: Add support for calling POSIX query info here, but passing in fid */
420415 rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb,
421416 xid, fid);
422417 if (newinode) {
....@@ -472,7 +467,7 @@
472467 struct tcon_link *tlink;
473468 struct cifs_tcon *tcon;
474469 struct TCP_Server_Info *server;
475
- struct cifs_fid fid;
470
+ struct cifs_fid fid = {};
476471 struct cifs_pending_open open;
477472 __u32 oplock;
478473 struct cifsFileInfo *file_info;
....@@ -620,20 +615,10 @@
620615 {
621616 int rc = -EPERM;
622617 unsigned int xid;
623
- int create_options = CREATE_NOT_DIR | CREATE_OPTION_SPECIAL;
624618 struct cifs_sb_info *cifs_sb;
625619 struct tcon_link *tlink;
626620 struct cifs_tcon *tcon;
627
- struct cifs_io_parms io_parms;
628621 char *full_path = NULL;
629
- struct inode *newinode = NULL;
630
- __u32 oplock = 0;
631
- struct cifs_fid fid;
632
- struct cifs_open_parms oparms;
633
- FILE_ALL_INFO *buf = NULL;
634
- unsigned int bytes_written;
635
- struct win_dev *pdev;
636
- struct kvec iov[2];
637622
638623 if (!old_valid_dev(device_number))
639624 return -EINVAL;
....@@ -653,103 +638,12 @@
653638 goto mknod_out;
654639 }
655640
656
- if (tcon->unix_ext) {
657
- struct cifs_unix_set_info_args args = {
658
- .mode = mode & ~current_umask(),
659
- .ctime = NO_CHANGE_64,
660
- .atime = NO_CHANGE_64,
661
- .mtime = NO_CHANGE_64,
662
- .device = device_number,
663
- };
664
- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
665
- args.uid = current_fsuid();
666
- args.gid = current_fsgid();
667
- } else {
668
- args.uid = INVALID_UID; /* no change */
669
- args.gid = INVALID_GID; /* no change */
670
- }
671
- rc = CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
672
- cifs_sb->local_nls,
673
- cifs_remap(cifs_sb));
674
- if (rc)
675
- goto mknod_out;
676
-
677
- rc = cifs_get_inode_info_unix(&newinode, full_path,
678
- inode->i_sb, xid);
679
-
680
- if (rc == 0)
681
- d_instantiate(direntry, newinode);
682
- goto mknod_out;
683
- }
684
-
685
- if (!S_ISCHR(mode) && !S_ISBLK(mode))
686
- goto mknod_out;
687
-
688
- if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
689
- goto mknod_out;
690
-
691
-
692
- cifs_dbg(FYI, "sfu compat create special file\n");
693
-
694
- buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
695
- if (buf == NULL) {
696
- rc = -ENOMEM;
697
- goto mknod_out;
698
- }
699
-
700
- if (backup_cred(cifs_sb))
701
- create_options |= CREATE_OPEN_BACKUP_INTENT;
702
-
703
- oparms.tcon = tcon;
704
- oparms.cifs_sb = cifs_sb;
705
- oparms.desired_access = GENERIC_WRITE;
706
- oparms.create_options = create_options;
707
- oparms.disposition = FILE_CREATE;
708
- oparms.path = full_path;
709
- oparms.fid = &fid;
710
- oparms.reconnect = false;
711
-
712
- if (tcon->ses->server->oplocks)
713
- oplock = REQ_OPLOCK;
714
- else
715
- oplock = 0;
716
- rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, buf);
717
- if (rc)
718
- goto mknod_out;
719
-
720
- /*
721
- * BB Do not bother to decode buf since no local inode yet to put
722
- * timestamps in, but we can reuse it safely.
723
- */
724
-
725
- pdev = (struct win_dev *)buf;
726
- io_parms.pid = current->tgid;
727
- io_parms.tcon = tcon;
728
- io_parms.offset = 0;
729
- io_parms.length = sizeof(struct win_dev);
730
- iov[1].iov_base = buf;
731
- iov[1].iov_len = sizeof(struct win_dev);
732
- if (S_ISCHR(mode)) {
733
- memcpy(pdev->type, "IntxCHR", 8);
734
- pdev->major = cpu_to_le64(MAJOR(device_number));
735
- pdev->minor = cpu_to_le64(MINOR(device_number));
736
- rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
737
- &bytes_written, iov, 1);
738
- } else if (S_ISBLK(mode)) {
739
- memcpy(pdev->type, "IntxBLK", 8);
740
- pdev->major = cpu_to_le64(MAJOR(device_number));
741
- pdev->minor = cpu_to_le64(MINOR(device_number));
742
- rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
743
- &bytes_written, iov, 1);
744
- }
745
- tcon->ses->server->ops->close(xid, tcon, &fid);
746
- d_drop(direntry);
747
-
748
- /* FIXME: add code here to set EAs */
641
+ rc = tcon->ses->server->ops->make_node(xid, inode, direntry, tcon,
642
+ full_path, mode,
643
+ device_number);
749644
750645 mknod_out:
751646 kfree(full_path);
752
- kfree(buf);
753647 free_xid(xid);
754648 cifs_put_tlink(tlink);
755649 return rc;
....@@ -807,7 +701,9 @@
807701 cifs_dbg(FYI, "Full path: %s inode = 0x%p\n",
808702 full_path, d_inode(direntry));
809703
810
- if (pTcon->unix_ext) {
704
+ if (pTcon->posix_extensions)
705
+ rc = smb311_posix_get_inode_info(&newInode, full_path, parent_dir_inode->i_sb, xid);
706
+ else if (pTcon->unix_ext) {
811707 rc = cifs_get_inode_info_unix(&newInode, full_path,
812708 parent_dir_inode->i_sb, xid);
813709 } else {