if (dir == MACH_PORT_NULL)
return -1;
- /* Create a new, unlinked node in the target directory. */
- err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node);
+ if (! *n)
+ /* Can't bind on the existing directory itself. */
+ err = ENOTDIR;
+ else
+ /* Create a new, unlinked node in the target directory. */
+ err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node);
if (! err)
{
todir = __file_name_split_at (tofd, to, &toname);
if (todir != MACH_PORT_NULL)
{
- err = __dir_link (todir, linknode, toname, 1);
+ if (! *toname)
+ /* Can't link to the existing directory itself. */
+ err = ENOTDIR;
+ else
+ err = __dir_link (todir, linknode, toname, 1);
__mach_port_deallocate (__mach_task_self (), todir);
}
__mach_port_deallocate (__mach_task_self (), linknode);
if (dir == MACH_PORT_NULL)
return -1;
- /* Create a new, unlinked node in the target directory. */
- errnode = err = __dir_mkfile (dir, O_WRITE, (mode & ~S_IFMT) & ~_hurd_umask, &node);
+ if (! *name)
+ /* Can't link to the existing directory itself. */
+ errnode = err = ENOTDIR;
+ else
+ /* Create a new, unlinked node in the target directory. */
+ errnode = err = __dir_mkfile (dir, O_WRITE, (mode & ~S_IFMT) & ~_hurd_umask, &node);
if (! err && translator != NULL)
/* Set the node's translator to make it a device. */
if (dir == MACH_PORT_NULL)
return -1;
- /* Create a new, unlinked node in the target directory. */
- err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
+ if (! *name)
+ /* Can't link to the existing directory itself. */
+ err = ENOTDIR;
+ else
+ /* Create a new, unlinked node in the target directory. */
+ err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
if (! err)
{