Initializes the boot sector and file system for the device. The file
system created by this method will always be in read-write mode.

@return the file system that was created
@throws IOException on write error
501695
public FatFileSystem format() throws IOException {
        final int sectorSize = device.getSectorSize();
        final int totalSectors = (int)(device.getSize() / sectorSize);
        
        final FsInfoSector fsi;
        final BootSector bs;
        if (sectorsPerCluster == 0) throw new AssertionError();
        
        if (fatType == FatType.FAT32) {
            bs = new Fat32BootSector(device);
            initBootSector(bs);
            
            final Fat32BootSector f32bs = (Fat32BootSector) bs;
            
            f32bs.setFsInfoSectorNr(1);
            
            f32bs.setSectorsPerFat(sectorsPerFat(0, totalSectors));
            final Random rnd = new Random(System.currentTimeMillis());
            f32bs.setFileSystemId(rnd.nextInt());
            
            f32bs.setVolumeLabel(label);
            
            /* create FS info sector */
            fsi = FsInfoSector.create(f32bs);
        } else {
            bs = new Fat16BootSector(device);
            initBootSector(bs);
            
            final Fat16BootSector f16bs = (Fat16BootSector) bs;
            
            final int rootDirEntries = rootDirectorySize(
                    device.getSectorSize(), totalSectors);
                    
            f16bs.setRootDirEntryCount(rootDirEntries);
            f16bs.setSectorsPerFat(sectorsPerFat(rootDirEntries, totalSectors));
            if (label != null) f16bs.setVolumeLabel(label);
            fsi = null;
        }
        
        final Fat fat = Fat.create(bs, 0);
        
        final AbstractDirectory rootDirStore;
        if (fatType == FatType.FAT32) {
            rootDirStore = ClusterChainDirectory.createRoot(fat);
            fsi.setFreeClusterCount(fat.getFreeClusterCount());
            fsi.setLastAllocatedCluster(fat.getLastAllocatedCluster());
            fsi.write();
        } else {
            rootDirStore = Fat16RootDirectory.create((Fat16BootSector) bs);
        }
        
        final FatLfnDirectory rootDir =
                new FatLfnDirectory(rootDirStore, fat, false);
        
        rootDir.flush();
        
        for (int i = 0; i < bs.getNrFats(); i++) {
            fat.writeCopy(bs.getFatOffset(i));
        }
        
        bs.write();
        
        /* possibly write boot sector copy */
        if (fatType == FatType.FAT32) {
            Fat32BootSector f32bs = (Fat32BootSector) bs;    
            f32bs.writeCopy(device);
        }
        
        FatFileSystem fs = FatFileSystem.read(device, false);

        if (label != null) {
            fs.setVolumeLabel(label);
        }

        fs.flush();
        return fs;
    }
503837
public byte[] toByteArray() throws IOException {
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(byteOut);
        out.writeObject(this);
        return byteOut.toByteArray();
    }
828888
private void createLibFolder() throws IOException {
        if(!Files.exists(libLocation.toPath()))
            Files.createDirectories(libLocation.toPath());
    }
245205
public File output() throws IOException {
        File o = new File(output);
        if (!o.exists() && !o.mkdirs()) {
            throw new IOException("Unable to create output folder '" + output + "'");
        }
        return o;
    }
531076
public static JimfsFileSystem newFileSystem(
      JimfsFileSystemProvider provider, URI uri, Configuration config) throws IOException {
    PathService pathService = new PathService(config);
    FileSystemState state = new FileSystemState(removeFileSystemRunnable(uri));

    JimfsFileStore fileStore = createFileStore(config, pathService, state);
    FileSystemView defaultView = createDefaultView(config, fileStore, pathService);
    WatchServiceConfiguration watchServiceConfig = config.watchServiceConfig;

    JimfsFileSystem fileSystem =
        new JimfsFileSystem(provider, uri, fileStore, pathService, defaultView, watchServiceConfig);

    pathService.setFileSystem(fileSystem);
    return fileSystem;
  }
415819
void successfulBoot() throws ConfigurationPersistenceException {
        synchronized (this) {
            if (doneBootup.get()) {
                return;
            }
            final File copySource;
            if (!interactionPolicy.isReadOnly()) {
                copySource = mainFile;
            } else {

                if ( FilePersistenceUtils.isParentFolderWritable(mainFile) ) {
                    copySource = new File(mainFile.getParentFile(), mainFile.getName() + ".boot");
                } else{
                    copySource = new File(configurationDir, mainFile.getName() + ".boot");
                }

                FilePersistenceUtils.deleteFile(copySource);
            }

            try {
                if (!bootFile.equals(copySource)) {
                    FilePersistenceUtils.copyFile(bootFile, copySource);
                }

                createHistoryDirectory();

                final File historyBase = new File(historyRoot, mainFile.getName());
                lastFile = addSuffixToFile(historyBase, LAST);
                final File boot = addSuffixToFile(historyBase, BOOT);
                final File initial = addSuffixToFile(historyBase, INITIAL);

                if (!initial.exists()) {
                    FilePersistenceUtils.copyFile(copySource, initial);
                }

                FilePersistenceUtils.copyFile(copySource, lastFile);
                FilePersistenceUtils.copyFile(copySource, boot);
            } catch (IOException e) {
                throw ControllerLogger.ROOT_LOGGER.failedToCreateConfigurationBackup(e, bootFile);
            } finally {
                if (interactionPolicy.isReadOnly()) {
                    //Delete the temporary file
                    try {
                        FilePersistenceUtils.deleteFile(copySource);
                    } catch (Exception ignore) {
                    }
                }
            }
            doneBootup.set(true);
        }
    }
737412
public function bootstrap()
    {
        if (! $this->runningInConsole && $this->initializeFs()) {
            $this->buildFsTree();
            $this->initialized = true;
        }

        return $this->initialized;
    }
944345
Path[] getLocalDirs() throws IOException{
    String[] localDirs = getLocalDirsFromConf(fConf);
    Path[] paths = new Path[localDirs.length];
    FileSystem localFs = FileSystem.getLocal(fConf);
    for (int i = 0; i < localDirs.length; i++) {
      paths[i] = new Path(localDirs[i]);
      paths[i] = paths[i].makeQualified(localFs);
    }
    return paths;
  }
1327112
private boolean setup() throws IOException {
    estimateSavings();

    final String randomId = getRandomId();
    JobClient jClient = new JobClient(jobconf);
    Path jobdir = new Path(jClient.getSystemDir(), NAME + "_" + randomId);

    LOG.info(JOB_DIR_LABEL + "=" + jobdir);
    jobconf.set(JOB_DIR_LABEL, jobdir.toString());
    Path log = new Path(jobdir, "_logs");

    // The control file should have small size blocks. This helps
    // in spreading out the load from mappers that will be spawned.
    jobconf.setInt("dfs.blocks.size",  OP_LIST_BLOCK_SIZE);

    FileOutputFormat.setOutputPath(jobconf, log);
    LOG.info("log=" + log);

    // create operation list
    FileSystem fs = jobdir.getFileSystem(jobconf);
    Path opList = new Path(jobdir, "_" + OP_LIST_LABEL);
    jobconf.set(OP_LIST_LABEL, opList.toString());
    int opCount = 0, synCount = 0;
    SequenceFile.Writer opWriter = null;

    try {
      opWriter = SequenceFile.createWriter(fs, jobconf, opList, Text.class,
          PolicyInfo.class, SequenceFile.CompressionType.NONE);
      for (RaidPolicyPathPair p : raidPolicyPathPairList) {
        // If a large set of files are Raided for the first time, files
        // in the same directory that tend to have the same size will end up
        // with the same map. This shuffle mixes things up, allowing a better
        // mix of files.
        java.util.Collections.shuffle(p.srcPaths);
        for (EncodingCandidate ec : p.srcPaths) {
          opWriter.append(new Text(ec.toString()), p.policy);
          opCount++;
          if (++synCount > SYNC_FILE_MAX) {
            opWriter.sync();
            synCount = 0;
          }
        }
      }

    } finally {
      if (opWriter != null) {
        opWriter.close();
      }
      fs.setReplication(opList, OP_LIST_REPLICATION); // increase replication for control file
    }
    raidPolicyPathPairList.clear();
    
    jobconf.setInt(OP_COUNT_LABEL, opCount);
    LOG.info("Number of files=" + opCount);
    jobconf.setNumMapTasks(getMapCount(opCount));
    LOG.info("jobName= " + jobName + " numMapTasks=" + jobconf.getNumMapTasks());
    return opCount != 0;

  }
54514
public static AzureCliCredentials create() throws IOException {
        return create(
            Paths.get(System.getProperty("user.home"), ".azure", "azureProfile.json").toFile(),
            Paths.get(System.getProperty("user.home"), ".azure", "accessTokens.json").toFile());
    }
236371
public Configuration initializeConf(String[] keys,
      Configuration conf, FileSystem fs) throws IOException {
    Configuration newConf = new Configuration(conf);
    if (fs == null) {
      fs = FileSystem.get(conf);
    }
    String suffix = fs.getUri().getAuthority();
    for (String key: keys) {
      String value = conf.get(key + "." + suffix);
      if (value != null) {
        newConf.set(key, value);
      }
    }
    return newConf;
  }
1252483
public void initialize(URI name, Configuration conf) throws IOException {
    // if an underlying fs has not already been specified,
    // create and initialize one
    if (this.fs == null) {
      Class<?> clazz = conf.getClass("fs.apitrace.underlyingfs.impl",
                                     DistributedFileSystem.class);
      if (clazz == null) {
        throw new IOException("No FileSystem for fs.apitrace.underlyingfs.impl.");
      }

      this.fs = (FileSystem)ReflectionUtils.newInstance(clazz, null);
      super.initialize(name, conf);
    }

    // trace conf options
    for (String opt : traceConfOpts) {
      APITrace.CallEvent ce = new APITrace.CallEvent();
      ce.logCall(APITrace.COMMENT_msg, null,
                 new Object[] {opt, conf.get(opt, "")});
    }
  }
206510
public void initialize() throws IOException  {
    rootEntry.refresh(rootEntry.getPath());
    final FileStatusEntry[] children = doListPathsEntry(rootEntry.getPath(), rootEntry);
    rootEntry.setChildren(children);
  }
758494
public int refreshNodes() throws IOException {
    int exitCode = -1;

    DistributedFileSystem dfs = getDFS();
    if (dfs == null) {
      System.err.println("FileSystem is " + getFS().getUri());
      return exitCode;
    }

    dfs.refreshNodes();
    exitCode = 0;
   
    return exitCode;
  }
896546
public int finalizeUpgrade() throws IOException {
    int exitCode = -1;

    DistributedFileSystem dfs = getDFS();
    if (dfs == null) {
      System.out.println("FileSystem is " + getFS().getUri());
      return exitCode;
    }

    dfs.finalizeUpgrade();
    exitCode = 0;
   
    return exitCode;
  }
292828
public static void initialize() {
    String homeDirName = System.getProperty("jdcp.home");
    File homeDir;
    if (homeDirName != null) {
      homeDir = new File(homeDirName);
    } else {
      homeDir = FileUtil.getApplicationDataDirectory("jdcp");
      System.setProperty("jdcp.home", homeDir.getPath());
    }
    homeDir.mkdir();
    if (System.getProperty("derby.system.home") == null) {
      System.setProperty("derby.system.home", homeDir.getPath());
    }
  }
440890
public static synchronized SystemConfiguration createSystemConfiguration()
            throws IOException {
        if (self == null) {
            if (getenv(BELFRAMEWORK_HOME_ENV_VAR) == null) {
                String err = MISSING_SYSCFG;
                err = err.concat(": environment variable not set ");
                err = err.concat(BELFRAMEWORK_HOME_ENV_VAR);
                throw new IOException(err);
            }
            self = new SystemConfiguration();
        }
        return self;
    }