1942 long do_mount(char *dev_name, char *dir_name, char *type_page, 1943 unsigned long flags, void *data_page) 1944 { 1945 struct path path; 1946 int retval = 0; 1947 int mnt_flags = 0; 1948 1949 /* Discard magic */ 1950 if ((flags & MS_MGC_MSK) == MS_MGC_VAL) 1951 flags &= ~MS_MGC_MSK; 1952 1953 /* Basic sanity checks */ 1954 1955 if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE)) 1956 return -EINVAL; 1957 1958 if (data_page) 1959 ((char *)data_page)[PAGE_SIZE - 1] = 0; 1960 1961 /* ... and get the mountpoint */ 1962 retval = kern_path(dir_name, LOOKUP_FOLLOW, &path); 1963 if (retval) 1964 return retval; 1965 1966 retval = security_sb_mount(dev_name, &path, 1967 type_page, flags, data_page); 1968 if (retval) 1969 goto dput_out; 1970 1971 /* Default to relatime unless overriden */ 1972 if (!(flags & MS_NOATIME)) 1973 mnt_flags |= MNT_RELATIME; 1974 1975 /* Separate the per-mountpoint flags */ 1976 if (flags & MS_NOSUID) 1977 mnt_flags |= MNT_NOSUID; 1978 if (flags & MS_NODEV) 1979 mnt_flags |= MNT_NODEV; 1980 if (flags & MS_NOEXEC) 1981 mnt_flags |= MNT_NOEXEC; 1982 if (flags & MS_NOATIME) 1983 mnt_flags |= MNT_NOATIME; 1984 if (flags & MS_NODIRATIME) 1985 mnt_flags |= MNT_NODIRATIME; 1986 if (flags & MS_STRICTATIME) 1987 mnt_flags &= ~(MNT_RELATIME | MNT_NOATIME); 1988 if (flags & MS_RDONLY) 1989 mnt_flags |= MNT_READONLY; 1990 1991 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN | 1992 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT | 1993 MS_STRICTATIME); 1994 1995 if (flags & MS_REMOUNT) 1996 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags, 1997 data_page); 1998 else if (flags & MS_BIND) 1999 retval = do_loopback(&path, dev_name, flags & MS_REC); 2000 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) 2001 retval = do_change_type(&path, flags); 2002 else if (flags & MS_MOVE) 2003 retval = do_move_mount(&path, dev_name); 2004 else 2005 retval = do_new_mount(&path, type_page, flags, mnt_flags, 2006 dev_name, data_page); 2007 dput_out: 2008 path_put(&path); 2009 return retval; 2010 }
|