Rev 4201 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4201 | Rev 4296 | ||
---|---|---|---|
Line 89... | Line 89... | ||
89 | int phone; |
89 | int phone; |
90 | futex_down(&rootfs_futex); |
90 | futex_down(&rootfs_futex); |
91 | if (rootfs.fs_handle) { |
91 | if (rootfs.fs_handle) { |
92 | /* We already have the root FS. */ |
92 | /* We already have the root FS. */ |
93 | rwlock_write_lock(&namespace_rwlock); |
93 | rwlock_write_lock(&namespace_rwlock); |
94 | if ((strlen(mp) == 1) && (mp[0] == '/')) { |
94 | if (str_cmp(mp, "/") == 0) { |
95 | /* Trying to mount root FS over root FS */ |
95 | /* Trying to mount root FS over root FS */ |
96 | rwlock_write_unlock(&namespace_rwlock); |
96 | rwlock_write_unlock(&namespace_rwlock); |
97 | futex_up(&rootfs_futex); |
97 | futex_up(&rootfs_futex); |
98 | ipc_answer_0(rid, EBUSY); |
98 | ipc_answer_0(rid, EBUSY); |
99 | return; |
99 | return; |
Line 122... | Line 122... | ||
122 | * This prevents the mount point from being deleted. |
122 | * This prevents the mount point from being deleted. |
123 | */ |
123 | */ |
124 | rwlock_write_unlock(&namespace_rwlock); |
124 | rwlock_write_unlock(&namespace_rwlock); |
125 | } else { |
125 | } else { |
126 | /* We still don't have the root file system mounted. */ |
126 | /* We still don't have the root file system mounted. */ |
127 | if ((strlen(mp) == 1) && (mp[0] == '/')) { |
127 | if (str_cmp(mp, "/") == 0) { |
128 | vfs_lookup_res_t mr_res; |
128 | vfs_lookup_res_t mr_res; |
129 | vfs_node_t *mr_node; |
129 | vfs_node_t *mr_node; |
130 | ipcarg_t rindex; |
130 | ipcarg_t rindex; |
131 | ipcarg_t rsize; |
131 | ipcarg_t rsize; |
132 | ipcarg_t rlnkcnt; |
132 | ipcarg_t rlnkcnt; |
Line 802... | Line 802... | ||
802 | ipc_answer_0(rid, EOK); |
802 | ipc_answer_0(rid, EOK); |
803 | } |
803 | } |
804 | 804 | ||
805 | void vfs_rename(ipc_callid_t rid, ipc_call_t *request) |
805 | void vfs_rename(ipc_callid_t rid, ipc_call_t *request) |
806 | { |
806 | { |
807 | size_t len; |
807 | size_t olen, nlen; |
808 | ipc_callid_t callid; |
808 | ipc_callid_t callid; |
809 | int rc; |
809 | int rc; |
810 | 810 | ||
811 | /* Retrieve the old path. */ |
811 | /* Retrieve the old path. */ |
812 | if (!ipc_data_write_receive(&callid, &len)) { |
812 | if (!ipc_data_write_receive(&callid, &olen)) { |
813 | ipc_answer_0(callid, EINVAL); |
813 | ipc_answer_0(callid, EINVAL); |
814 | ipc_answer_0(rid, EINVAL); |
814 | ipc_answer_0(rid, EINVAL); |
815 | return; |
815 | return; |
816 | } |
816 | } |
817 | char *old = malloc(len + 1); |
817 | char *old = malloc(olen + 1); |
818 | if (!old) { |
818 | if (!old) { |
819 | ipc_answer_0(callid, ENOMEM); |
819 | ipc_answer_0(callid, ENOMEM); |
820 | ipc_answer_0(rid, ENOMEM); |
820 | ipc_answer_0(rid, ENOMEM); |
821 | return; |
821 | return; |
822 | } |
822 | } |
823 | if ((rc = ipc_data_write_finalize(callid, old, len))) { |
823 | if ((rc = ipc_data_write_finalize(callid, old, olen))) { |
824 | ipc_answer_0(rid, rc); |
824 | ipc_answer_0(rid, rc); |
825 | free(old); |
825 | free(old); |
826 | return; |
826 | return; |
827 | } |
827 | } |
828 | old[len] = '\0'; |
828 | old[olen] = '\0'; |
829 | 829 | ||
830 | /* Retrieve the new path. */ |
830 | /* Retrieve the new path. */ |
831 | if (!ipc_data_write_receive(&callid, &len)) { |
831 | if (!ipc_data_write_receive(&callid, &nlen)) { |
832 | ipc_answer_0(callid, EINVAL); |
832 | ipc_answer_0(callid, EINVAL); |
833 | ipc_answer_0(rid, EINVAL); |
833 | ipc_answer_0(rid, EINVAL); |
834 | free(old); |
834 | free(old); |
835 | return; |
835 | return; |
836 | } |
836 | } |
837 | char *new = malloc(len + 1); |
837 | char *new = malloc(nlen + 1); |
838 | if (!new) { |
838 | if (!new) { |
839 | ipc_answer_0(callid, ENOMEM); |
839 | ipc_answer_0(callid, ENOMEM); |
840 | ipc_answer_0(rid, ENOMEM); |
840 | ipc_answer_0(rid, ENOMEM); |
841 | free(old); |
841 | free(old); |
842 | return; |
842 | return; |
843 | } |
843 | } |
844 | if ((rc = ipc_data_write_finalize(callid, new, len))) { |
844 | if ((rc = ipc_data_write_finalize(callid, new, nlen))) { |
845 | ipc_answer_0(rid, rc); |
845 | ipc_answer_0(rid, rc); |
846 | free(old); |
846 | free(old); |
847 | free(new); |
847 | free(new); |
848 | return; |
848 | return; |
849 | } |
849 | } |
850 | new[len] = '\0'; |
850 | new[nlen] = '\0'; |
851 | 851 | ||
852 | char *oldc = canonify(old, &len); |
852 | char *oldc = canonify(old, &olen); |
853 | char *newc = canonify(new, NULL); |
853 | char *newc = canonify(new, &nlen); |
854 | if (!oldc || !newc) { |
854 | if (!oldc || !newc) { |
855 | ipc_answer_0(rid, EINVAL); |
855 | ipc_answer_0(rid, EINVAL); |
856 | free(old); |
856 | free(old); |
857 | free(new); |
857 | free(new); |
858 | return; |
858 | return; |
859 | } |
859 | } |
- | 860 | oldc[olen] = '\0'; |
|
- | 861 | newc[nlen] = '\0'; |
|
860 | if (!strncmp(newc, oldc, len)) { |
862 | if (!str_lcmp(newc, oldc, str_length(oldc))) { |
861 | /* oldc is a prefix of newc */ |
863 | /* oldc is a prefix of newc */ |
862 | ipc_answer_0(rid, EINVAL); |
864 | ipc_answer_0(rid, EINVAL); |
863 | free(old); |
865 | free(old); |
864 | free(new); |
866 | free(new); |
865 | return; |
867 | return; |